From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Sweth Chandramouli <sweth@astaroth.nit.gwu.edu>,
zsh-users@sunsite.auc.dk
Subject: Re: setopt and alias questions
Date: Fri, 12 Feb 1999 12:13:57 -0800 [thread overview]
Message-ID: <990212121357.ZM11167@candle.brasslantern.com> (raw)
In-Reply-To: <19990212143425.A23452@astaroth.nit.gwu.edu>
On Feb 12, 2:34pm, Sweth Chandramouli wrote:
> Subject: Re: setopt and alias questions
> On Mon, Feb 08, 1999 at 12:55:00PM -0800, Bart Schaefer wrote:
> > That won't work either (and my remark about "unless there happens to be a
> > file in the current directory" is wrong as well). Filename generation is
> > not applied to the strings inside the [[ ... ]].
>
> are you sure about this? the above (with -n instead of -x) works
> fine for me--or at least, the filename generation part does.
Did you try running the fx function? Here it is again:
function fx() {
mkdir /tmp/x
echo "echo hello" > /tmp/x/x
chmod +x /tmp/x/x
echo /tmp/x/*(x)
[[ -n /tmp/x/*(x) ]] && echo Got nonzero string
[[ -f /tmp/x/*(x) ]] && echo Globbed a file
[[ -x /tmp/x/*(x) ]] && echo Globbed executable file
[[ -x /tmp/x/x ]] && echo Found executable file
rm -r /tmp/x
[[ -n /tmp/x/*(x) ]] && echo Still got nonzero string
[[ -x /tmp/x/x ]] || echo Found no executable file
}
The output I get is:
zagzig% fx
/tmp/x/x
Got nonzero string
Found executable file
Still got nonzero string
Found no executable file
Note that "Globbed ..." was never output. If I replace all the [[ ... ]]
with [ ... ] (single brackets), THEN I get
zagzig% fx
/tmp/x/x
Got nonzero string
Globbed a file
Globbed executable file
Found executable file
zsh: no matches found: /tmp/x/*(x)
> could a flag be added to the list of glob qualifiers that says "if no
> matches are found, quietly return nothing but a non-zero exit status"? i
> think "q" (for "quiet") is still free.
There already is such a flag; it's (N) for NULL_GLOB, which acts like:
zagzig% setopt nullglob
zagzig% fx
/tmp/x/x
Got nonzero string
Globbed a file
Globbed executable file
Found executable file
Still got nonzero string
Found no executable file
(This again with [ ... ] but NOT with [[ ... ]].)
next prev parent reply other threads:[~1999-02-12 20:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-02-08 0:37 Sweth Chandramouli
1999-02-08 1:59 ` Bart Schaefer
1999-02-08 4:52 ` Sweth Chandramouli
1999-02-08 7:33 ` Bart Schaefer
1999-02-08 15:30 ` Sweth Chandramouli
1999-02-08 18:45 ` Bart Schaefer
1999-02-08 19:15 ` Sweth Chandramouli
1999-02-08 19:44 ` Bart Schaefer
1999-02-08 19:59 ` Sweth Chandramouli
1999-02-08 20:55 ` Bart Schaefer
1999-02-12 19:34 ` Sweth Chandramouli
1999-02-12 20:13 ` Bart Schaefer [this message]
1999-02-08 19:46 ` Sweth Chandramouli
1999-02-08 20:30 ` Bart Schaefer
1999-02-09 8:40 ` Phil Pennock
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=990212121357.ZM11167@candle.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=sweth@astaroth.nit.gwu.edu \
--cc=zsh-users@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).