On Fri, Feb 04, 2022 at 02:52:34AM +0700, Robert Elz wrote: > You could instead use: > > my() > { > local A= > while [ $# -gt 0 ] > do > case "$1" in > int) A="${A} -i";; > map) A="${A} -A";; > array) A="${A} -a";; > ....) # as many more as you need > *) break;; > esac > shift > done > declare $A -- "$@" > } > int() { my int "$@"; } > array() { my array "$@"; } > (etc)
This declares the variables at the wrong scope. They won't be usable in the function where you call "my". In order to make this work, you'd need something equivalent to Tcl's uplevel command. That said, I agree with your point, and I would never use the things that Ms. Walsh is advocating.