Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
NOMATCH errors
- X-seq: zsh-users 22332
- From: Anthony Heading <anthony@xxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: NOMATCH errors
- Date: Thu, 05 Jan 2017 22:35:21 -0500
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=ajrh.net; h= content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= mesmtp; bh=r47Lj8CwZzonyor6vVF1clMGpTo=; b=r54q8JPNEfgDS+1+aqSlB wViAb0fZne+ArTd/B7b7hjheY0UHWqs4zjNWAwCmBlkXPCtSLdkVcarz/KIyXerR KBDHfQNxDhDolKnZ9j7U0yz881Wzpt98ZIP5pGvMxvD3NiwqPKSVZLrRhs7nDLqU 5o4Dh6Vs7qCXgLOeqjDgKU=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=smtpout; bh=r47Lj8CwZzonyor6vVF1clMGp To=; b=I+Uf0o4Y/TmABu7G+2yamravbaGnGJ1bKs4JFwafsgv9N3tNAfVx4jnQf CsYpAEX1G50Kcip7McgYimJGRQZBan3gngogysuCbqn01yQbV+O8HBoQs7Tviiwn qr1u7tUUk7bXSZ6cHlYa+4Jx0mhnniXVhFDWpST5BsuRdPZkhA=
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
Hi,
I was dusting off an old script which, admittedly inelegantly, did
PYTHON==python 2>/dev/null
with NOMATCH set, which in the zsh 5 era seems to be a fatal error, i.e.
a script
echo hello
echo =hello =hello
echo "is there anybody in there?"
doesn't get past:
hello
hello:2: hello not found
Interestingly the docs perhaps arguably seem to imply differently:
Fatal errors found in non-interactive shells include:
[...]
o File generation failures where not caused by NO_MATCH or similar
options
So I was wondering the cleanest way to do this. `which python` is the
old-school
way, I guess, but the documentation isn't very reassuring about output
format
in case it happens to be an alias or a function or (heaven forfend)
python becomes
a shell builtin.
I played for a few minutes with a trivial patch at the end of this
email, which
aimed to make ==missing expand to an empty string. That to me seems a
helpful
behaviour, enables e.g. ${${:-==python}:-perl}, although it feels very
special
case syntax, maybe something as a variant or modifier on the :c
expansion would be
neater. But then if the idea is valid, maybe it sense to be able to
soft test tilde dir
expansion too; I'm not aware a nice way to look up single entries in
the hash tables, so maybe a general syntax for that could be better.
Any thoughts appreciated, especially if I'm missing a neat way to do
this.
Thanks
Anthony
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -623,13 +623,18 @@ char *
equalsubstr(char *str, int assign, int nomatch)
{
char *pp, *cnam, *cmdstr, *ret;
+ int nullmatch = str[0] == Equals;
for (pp = str; !isend2(*pp); pp++)
;
cmdstr = dupstrpfx(str, pp-str);
untokenize(cmdstr);
remnulargs(cmdstr);
+ if (nullmatch)
+ cmdstr++;
if (!(cnam = findcmd(cmdstr, 1, 0))) {
+ if (nullmatch)
+ return dupstring("");
if (nomatch)
zerr("%s not found", cmdstr);
return NULL;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author