Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(( $+functions[dvar] )) || function dvar() {
local pre=''
test -z "$2" || pre="CODE $2 | "
echo "$pre$(typeset -p "$1" 2>&1)"
echo "$pre$1 in env: $(printenv "$1")"
}
localesc() {
echo Innocence
}
tlocalesc() {
dvar music_dir t0
local music_dir=outside1
dvar music_dir t1
# localesc
music_dir=hi localesc
dvar music_dir t2
}
@NightMachinary

This comment has been minimized.

Copy link
Owner Author

commented Aug 8, 2019

Somehow music_dir gets unset after calling tlocalesc.

$ zsh --version
zsh 5.7.1 (x86_64-apple-darwin18.6.0)
$ zsh -f
Fereidoons-MacBook-Pro% source ~/scripts/zsh/auto-load/scratchpad.zsh
Fereidoons-MacBook-Pro% dvar music_dir
dvar:typeset:3: no such variable: music_dir
music_dir in env:
Fereidoons-MacBook-Pro% music_dir=good
Fereidoons-MacBook-Pro% dvar music_dir
typeset -g music_dir=good
music_dir in env:
Fereidoons-MacBook-Pro% tlocalesc
CODE t0 | typeset -g music_dir=good
CODE t0 | music_dir in env:
CODE t1 | typeset -g music_dir=outside1
CODE t1 | music_dir in env:
Innocence
CODE t2 | typeset -g music_dir=outside1
CODE t2 | music_dir in env:
Fereidoons-MacBook-Pro% dvar music_dir
dvar:typeset:3: no such variable: music_dir
music_dir in env:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.