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 10178
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Style question: Can this be written in a more elegant way?
- Date: Mon, 24 Apr 2006 08:21:35 -0700
- In-reply-to: <444C8C0B.6090409@xxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <6F0CB04509C11D46A54232E852E390AC013D956D@xxxxxxxxxxxxxxxxxxxxxxxxxx> <444C8C0B.6090409@xxxxxxxxxxxxxxxxxx>
On Apr 24, 10:27am, Marc Chantreux wrote:
}
} Here is mine but i'm sure there is faster.
}
} file=( *(om) )
} (( $file[1] )) && PROG_SUCCESS || PROG_FAIL
I think you mean:
file=( X*(Nom[1]) )
(( $+file )) && PROG_SUCCESS $file || PROG_FAIL
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
Note that in the event that there are two or more files with the same
time stamp, there's no guarantee which one of them is chosen, and in
fact X*(om[1]) and X*(Om[1]) might both choose the same file.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author