Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
~ $ bash -x /dev/fd/9 9<<\EOF
FUNCNEST=5
# alias eval='eval ' function='function ' .fn='f { a+=( a.{0..9} ); }'
function f {
if [[ $1 ]]; then
typeset key
for key; do alias "a.${key}=$((n++))foo"; done
f
else
function f { a+=( a.{0..9} ); }
f
fi
}
f {0..9}; typeset -p a; alias -p
# vim: set fenc=utf-8 ff=unix ft=sh ts=2 sts=2 sw=2 et :
EOF
+ FUNCNEST=5
+ f 0 1 2 3 4 5 6 7 8 9
+ [[ -n 0 ]]
+ typeset key
+ for key in "$@"
+ alias a.0=0foo
+ for key in "$@"
+ alias a.1=1foo
+ for key in "$@"
+ alias a.2=2foo
+ for key in "$@"
+ alias a.3=3foo
+ for key in "$@"
+ alias a.4=4foo
+ for key in "$@"
+ alias a.5=5foo
+ for key in "$@"
+ alias a.6=6foo
+ for key in "$@"
+ alias a.7=7foo
+ for key in "$@"
+ alias a.8=8foo
+ for key in "$@"
+ alias a.9=9foo
+ f
+ [[ -n '' ]]
+ f
+ a+=(a.{0..9})
+ typeset -p a
declare -a a=([0]="a.0" [1]="a.1" [2]="a.2" [3]="a.3" [4]="a.4" [5]="a.5" [6]="a.6" [7]="a.7" [8]="a.8" [9]="a.9")
+ alias -p
alias a.0='0foo'
alias a.1='1foo'
alias a.2='2foo'
alias a.3='3foo'
alias a.4='4foo'
alias a.5='5foo'
alias a.6='6foo'
alias a.7='7foo'
alias a.8='8foo'
alias a.9='9foo'
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.