From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5876 invoked by alias); 6 Jan 2017 03:35:32 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 22332 Received: (qmail 4800 invoked from network); 6 Jan 2017 03:35:32 -0000 X-Qmail-Scanner-Diagnostics: from out2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.26):SA:0(-0.7/5.0):. Processed in 1.222354 secs); 06 Jan 2017 03:35:32 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: anthony@ajrh.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at spf.messagingengine.com designates 66.111.4.26 as permitted sender) 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= X-ME-Sender: Message-Id: <1483673721.1546772.838942313.0683A864@webmail.messagingengine.com> From: Anthony Heading To: zsh-users@zsh.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-Mailer: MessagingEngine.com Webmail Interface - ajax-34b48c55 Date: Thu, 05 Jan 2017 22:35:21 -0500 Subject: NOMATCH errors 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;