On Sat, May 1, 2010 at 12:26 PM, Dennis Williamson <dennistwilliam...@gmail.com> wrote: > As Chet said, use internal variables that are unlikely to conflict. > > # Param: $1 variable name to return value to > blackbox() { > local __bb_a # internal: __, blackbox: bb, a: _a > eval $1=bar > } > > f() { > local a > blackbox a > echo $a > } > f # no conflict > > I prefer to avoid using eval by using declare, but declare inside a > function makes the variable local. Wouldn't it be nice to have a > global flag (declare -g) like zsh's typeset -g. > > d='ls /;true' # aren't you glad it's not "rm -rf" instead of "ls" > f "$d" # oops
You can use workarounds like: printf -v $a "%s" foobar read $a <<< "%s"