Created
July 11, 2019 10:49
-
-
Save adoyle-h/4b1b09325b64c72844ea9112cad650fc to your computer and use it in GitHub Desktop.
bash nameref FML
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 | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
shopt -s inherit_errexit | |
[[ -n "${VERBOSE:-}" ]] && set -o verbose | |
[[ -n "${DEBUG:-}" ]] && IS_DEBUG=true || IS_DEBUG=false | |
foo() { | |
local -n a=$1 | |
local b=2 | |
echo "$a" | |
} | |
b=3 | |
foo b | |
# It prints 2 not 3. WTF! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment