Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Style question: Can this be written in a more elegant way?
- X-seq: zsh-users 10182
- From: Marc Chantreux <marc.chantreux@xxxxxxxxxxxxxxxxxx>
- Subject: Re: Style question: Can this be written in a more elegant way?
- Date: Tue, 25 Apr 2006 09:55:04 +0200
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <060424082135.ZM390@xxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <6F0CB04509C11D46A54232E852E390AC013D956D@xxxxxxxxxxxxxxxxxxxxxxxxxx> <444C8C0B.6090409@xxxxxxxxxxxxxxxxxx> <060424082135.ZM390@xxxxxxxxxxxxxxxxxxxxxx>
Hi Bart,
} file=( *(om) )
} (( $file[1] )) && PROG_SUCCESS || PROG_FAIL
I think you mean:
file=( X*(Nom[1]) )
(( $+file )) && PROG_SUCCESS $file || PROG_FAIL
I didn't : my lines was the best i've found.
- haven't thought about the N modifier
- I've tried something like *(om)[1,2] but it naturally failed. didn't
found the ([x]) in the doc.
but now i'll do mean!
However, that will run PROG_FAIL if PROG_SUCCESS fails, as well as if
there are no matching files. I don't think you can avoid if/else.
if (( $+file )); then PROG_SUCCESS $file; else PROG_FAIL; fi
i have noticed that a lot of people here don't use the alternative form.
is there a reason to not use the next line ?
if (( $+file )) { PROG_SUCCESS $file } else { PROG_FAIL }
BTW, i've tried another way to launch PROG_SUCCESS for the first file
but it failed because it execute the e:: code for all the files. Peraps
there is a trick i missed?
% ls
is score the this
% : *(Nom[1]e:echo last file $REPLY:)
last file score
last file score
last file score
last file score
regards
mc
Messages sorted by:
Reverse Date,
Date,
Thread,
Author