Created
March 29, 2019 19:04
-
-
Save jessamynsmith/67344a7c26cef59a273ec76ab64a2992 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Bash scope experiments | |
func () | |
{ | |
echo "in func: param1: $1, param2: $2, var1: $var1, var2: $var2" | |
} | |
var1=$1 | |
var2=$2 | |
echo "1: param1: $1, param2: $2, var1: $var1, var2: $var2" | |
func | |
echo "2: param1: $1, param2: $2, var1: $var1, var2: $var2" | |
Result of running the script: | |
$ sh test.sh hello world | |
1: param1: hello, param2: world, var1: hello, var2: world | |
in func: param1: , param2: , var1: hello, var2: world | |
2: param1: hello, param2: world, var1: hello, var2: world | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment