Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] respect nullglob given multios
- X-seq: zsh-workers 44808
- From: Joe Rice <jsrice@xxxxxxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: [PATCH] respect nullglob given multios
- Date: Thu, 10 Oct 2019 01:18:05 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1570670291; bh=Qmyb10DIyBmUyu97UTq6uJGCe79pFANrLcGOLrQTiMg=; h=Date:To:From:Reply-To:Subject:Feedback-ID:From; b=NhWx21h/5Bkt+0tkstxdDOUrPCvJ1idtVc8u6TgJaXjn2FFlq1EW9ba9DyNHZG2L2 mrBeBKZTQ7aYYM5Qe1Jv+In3rz0QUc80F+4Y5DtfemG91pQWXxlUVqXqWKKPUDr0T4 rpIii0Mt5Dfib5MeOSbFW/WKmzZjljaIYoHOxZCY=
- Feedback-id: zuUmUIiSanTclByPD4QM8577gj-MNEd1LLupye9O0Jn3hx3VaqOEMvk-3tX9osjU9S2JAO0ka4_drqQM-SjB3g==:Ext:ProtonMail
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Reply-to: Joe Rice <jsrice@xxxxxxxxxxxxxx>
This patch makes multios behave less surprisingly with nullglob.
Currently, multios throws a file not found error when a nullglob is given. This patch inserts /dev/null into the redirection list when the glob returns empty with no errors.
Is this a behavior that would interest anyone else? I find myself using the `cat /dev/null *(N.)` idiom quite a bit and I thought the behavior made sense for the null case in multios.
Joe
diff --git a/Src/glob.c b/Src/glob.c
index 92fd64e7c..a708dfb9a 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2116,8 +2116,11 @@ xpandredir(struct redir *fn, LinkList redirtab)
/* ...which undergoes all the usual shell expansions */
prefork(&fake, isset(MULTIOS) ? 0 : PREFORK_SINGLE, NULL);
/* Globbing is only done for multios. */
- if (!errflag && isset(MULTIOS))
+ if (!errflag && isset(MULTIOS)) {
globlist(&fake, 0);
+ if (empty(&fake) && !errflag && !badcshglob)
+ addlinknode(&fake, dupstring("/dev/null"));
+ }
if (errflag)
return 0;
if (nonempty(&fake) && !nextnode(firstnode(&fake))) {
Messages sorted by:
Reverse Date,
Date,
Thread,
Author