Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Suppressing "no matches found" Glob Message?
- X-seq: zsh-users 7617
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Suppressing "no matches found" Glob Message?
- Date: Tue, 29 Jun 2004 09:12:33 -0700 (PDT)
- In-reply-to: <20040628085300.GA1443@DervishD>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <2A3E94EA-C7E3-11D8-9C37-000502631FBD@xxxxxxxxxxxx> <20040627104222.GA237@DervishD> <6D3CE77E-C88C-11D8-A1EE-000A95EDC31A@xxxxxxxxxxxxxx> <20040628085300.GA1443@DervishD>
- Reply-to: zsh-users@xxxxxxxxxx
On Mon, 28 Jun 2004, DervishD wrote:
> In certain sense, what you want is impossible. If you issue the 'ls'
> command with parameters, it will list those parameters (if they exist),
> but if you don't give it params, it will list all files and dirs. You
> cannot have a way of 'ls' shutting its mouth up if the pattern doesn't
> match anything.
Well, no, but you can have zsh not call "ls" in the first place if the
pattern doesn't match anything.
You're on the right track in a later posting on this thread where you used
a function rather than an alias. Aliases can't do anything but simple
text replacements which happen before any of the glob patterns or other
expansions are evaluated. If you want to base a decision on the result of
an expansion, you must use a function.
In this case, something like
lspf() {
files=( **/*(.N) )
if (( $#files ))
then
ls $files
else
print -u2 "Dude, where's my file?"
fi
}
Of course, when I try that, I get "argument list too long: ls" but that's
a different issue.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author