Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Style question: Can this be written in a more elegant way?



Bart Schaefer wrote:
But (( $file[1] )) can't be right; it treats the file name as a math
expression, so a file named "3-3" would execute PROG_FAIL.  You must
at least mean (( ${+file[1]} )).

oopps ... that was forgotten when copy/paste ...


... you have failed to quote $REPLY so it substitutes the value that it
had before the glob began to execute.  It's as if you had typed:

% : *(Nom[1]e:echo last file score:)

Correct is like so:

% : *(Nom[1]e:'echo last file $REPLY':)
last file this
last file is
last file the
last file score

i got the first error ... but what i expect is to treat only the nth element of the list.

% : *(Nom[1]e:'echo last file $REPLY':)
last file this
% : *(Nom[2]e:'echo last file $REPLY':)
last file is
...

and so on ...

regards.
mc



Messages sorted by: Reverse Date, Date, Thread, Author