diff options
| author | Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> | 2025-12-21 12:46:04 +0900 |
|---|---|---|
| committer | Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> | 2025-12-21 12:54:51 +0900 |
| commit | 3e72a52e27d8ce8d8be0ee65ae5f77f756c06fda (patch) | |
| tree | 24fcb47088cc0360058a3accc148bfcf0c22c740 /Src/glob.c | |
| parent | 54150: the option --license was removed in 2010 (diff) | |
| download | zsh-master.tar zsh-master.tar.gz zsh-master.tar.bz2 zsh-master.tar.lz zsh-master.tar.xz zsh-master.tar.zst zsh-master.zip | |
when redirecting to/from a pattern (MULTIOS) and if there is no match,
issue an error even if NULL_GLOB is in effect.
Diffstat (limited to 'Src/glob.c')
| -rw-r--r-- | Src/glob.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Src/glob.c b/Src/glob.c index 9bfb0f895..e13481955 100644 --- a/Src/glob.c +++ b/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))) { |
