Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jessamynsmith/67344a7c26cef59a273ec76ab64a2992 to your computer and use it in GitHub Desktop.
Save jessamynsmith/67344a7c26cef59a273ec76ab64a2992 to your computer and use it in GitHub Desktop.
#!/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