Skip to content

Instantly share code, notes, and snippets.

@adoyle-h
Created July 11, 2019 10:49
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 adoyle-h/4b1b09325b64c72844ea9112cad650fc to your computer and use it in GitHub Desktop.
Save adoyle-h/4b1b09325b64c72844ea9112cad650fc to your computer and use it in GitHub Desktop.
bash nameref FML
#!/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