Skip to content

Instantly share code, notes, and snippets.

@joemiller
Last active September 24, 2020 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joemiller/5d400a76fde1ab4d497c22b6fa6d9dee to your computer and use it in GitHub Desktop.
Save joemiller/5d400a76fde1ab4d497c22b6fa6d9dee to your computer and use it in GitHub Desktop.
demo of bash vars global scope by default
#!/bin/bash
foo() {
op=$1
# local op=$1
echo "foo: op is $op"
}
main() {
op="main"
echo "main: $op"
foo "bar"
echo "main: $op"
}
main "$@"
@joemiller
Copy link
Author

$ bash foo.sh
main: main
foo: op is bar
main: bar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment