mirror of
https://git.code.sf.net/p/zsh/code
synced 2026-04-18 06:53:35 -04:00
53959+54149: fix a bug when redirecting to a pattern with no match
when redirecting to/from a pattern (MULTIOS) and if there is no match, issue an error even if NULL_GLOB is in effect.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2025-12-21 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
|
||||
|
||||
* 53959+54149: Src/glob.c, Test/D02glob.ztst: when redirecting
|
||||
to/from a pattern (MULTIOS) and if there is no match, issue an
|
||||
error even if NULL_GLOB is in effect.
|
||||
|
||||
2025-12-16 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* Christopher Bock: 54148: Completion/Debian/Command/_apt:
|
||||
|
||||
16
Src/glob.c
16
Src/glob.c
@@ -1202,6 +1202,9 @@ checkglobqual(char *str, int sl, int nobareglob, char **sp)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* notify zglob() that it is called from expandredir() */
|
||||
static int in_expandredir = 0;
|
||||
|
||||
/* Main entry point to the globbing code for filename globbing. *
|
||||
* np points to a node in the list which will be expanded *
|
||||
* into a series of nodes. */
|
||||
@@ -1882,6 +1885,14 @@ zglob(LinkList list, LinkNode np, int nountok)
|
||||
matchct = 1;
|
||||
}
|
||||
}
|
||||
else if (in_expandredir) {
|
||||
/* if completing for redirection, we can't remove the pattern
|
||||
* even if NULL_GLOB is in effect */
|
||||
zerr("redirection failed (no match): %s", ostr);
|
||||
zfree(matchbuf, 0);
|
||||
restore_globstate(saved);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(gf_sortlist[0].tp & GS_NONE)) {
|
||||
/*
|
||||
@@ -2148,8 +2159,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)) {
|
||||
in_expandredir = 1;
|
||||
globlist(&fake, 0);
|
||||
in_expandredir = 0;
|
||||
}
|
||||
if (errflag)
|
||||
return 0;
|
||||
if (nonempty(&fake) && !nextnode(firstnode(&fake))) {
|
||||
|
||||
@@ -541,6 +541,10 @@
|
||||
>No file beginning with z
|
||||
>Normal string if nullglob not set
|
||||
|
||||
echo > glob.tmp/nonexistent(N)
|
||||
1:redirect to a non-matching pattern is an error even with flag (N)
|
||||
?(eval):1: redirection failed (no match): glob.tmp/nonexistent(N)
|
||||
|
||||
(
|
||||
setopt extended_glob no_nomatch
|
||||
cd glob.tmp
|
||||
|
||||
Reference in New Issue
Block a user