Re: passing args without eval



On 1/23/2012 8:29 AM, Stephane Chazelas wrote:
2012-01-23 08:20:21 -0600, Ed Morton:
[...]
[af] ) optArgs[$OPTIND]="$OPTARG"
passargs="$passargs -$opt \"\${optArgs[$OPTIND]}\""
[...]
eval "sub $passargs \"\$@\""
[...]

If you're using arrays already, why are you using a scalar for
$passargs?

passargs+=("-$opt" "$OPTARG")
[...]
sub "$passargs[@]"

(zsh syntax).


In case anyone cares, I found with bash I need to add curly braces:

sub "${passargs[@]}"

I assume that'll work in zsh too.

Thanks again,

Ed.
.



Relevant Pages

  • Re: passing args without eval
    ... why are you using a scalar for ... (zsh syntax). ...
    (comp.unix.shell)
  • Re: Reintroducing fish, the friendly interactive shell
    ... That makes zsh patterns to involve fewer keystrokes. ... Note that zsh implemented globbing attributes (like case ... Isn't this just a new syntax for regular expressions? ...
    (comp.unix.shell)
  • Re: Reintroducing fish, the friendly interactive shell
    ... How does fish do that, does it do the equivalent of brace ... I would expect it to cancel the whole command. ... With zsh: ... syntax is terse so that it's faster to type. ...
    (comp.unix.shell)
  • Re: Reintroducing fish, the friendly interactive shell
    ... Or with zsh -o csh_null_glob ... This is one of the places where the csh syntax makes more sense ... Fish differes from rc in how multiple expansions in the same argument ... very dangerous to me (if you intend to write fish scripts). ...
    (comp.unix.shell)
  • Re: ] and [ ].
    ... that syntax comes from Plan9's rc and ... was first brought to the Bourne shell world by zsh, ... copied by ksh and then bash. ...
    (comp.unix.shell)