bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Incorrect alias expansion within command substitution


From: Greg Wooledge
Subject: Re: Incorrect alias expansion within command substitution
Date: Thu, 3 Feb 2022 16:19:08 -0500

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]