On Monday 17 June 2013 01:42:15 Mike Frysinger wrote: > On Sunday 02 June 2013 13:38:04 Steven J. Long wrote: > > On Sat, Jun 01, 2013 at 11:03:20PM -0400, Mike Frysinger wrote: > > > +# is not specified, the var will be unset. > > > +evar_push_set() { > > > + local var=$1 > > > + evar_push ${var} > > > + case $# in > > > + 1) unset ${var} ;; > > > + 2) eval ${var}=\$2 ;; > > > > I wish you wouldn't use eval for this. I know it's technically okay here, > > or would be if you verified the parameter, but bash has printf -v for > > this purpose: > > interesting, i hadn't seen that before ... looks new to bash-3.1. /me > tucks that into his tool belt. > > although it doesn't quite work in the edge case where the value is an empty > string. consider: > unset x > printf -v x '' > echo ${x+set} > > that should show "set", but it does not. i'll have to keep `eval ${var}=` > when the value we're setting is empty. or just keep the eval code since i > have to do eval anyways at that point. > > i'll report it upstream to the bash guys. looks like it can be worked around by doing: printf -v x '%s' '' which is arguably what we want anyways -mike