1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Make redirections like {varname}>file work with brace expansion off

This is some nonsense: redirections that store a file descriptor
greater than 9 in a variable, like {var}<&2 and the like, stopped
working if brace expansion was turned off. '{var}' is not a brace
expansion as it doesn't contain ',' or '..'; something like 'echo
{var}' is always output unexpanded. And redirections and brace
expansion are two completely unrelated things. It wasn't documented
that these redirections require the -B/braceexpand option, either.

src/cmd/ksh93/sh/lex.c: sh_lex():
- Remove incorrect check for braceexpand option before processing
  redirections of this form.

src/cmd/ksh93/COMPATIBILITY:
- Insert a brief item mentioning this.

src/cmd/ksh93/sh.1:
- Correction: these redirections do not yield a file descriptor >
  10, but > 9, a.k.a. >= 10.
- Add a brief example showing how these redirections can be used.

src/cmd/ksh93/tests/io.sh:
- Add a quick regression test.
This commit is contained in:
Martijn Dekker 2021-02-05 03:42:10 +00:00
parent c709868572
commit f9427909dc
6 changed files with 38 additions and 17 deletions

View file

@ -3557,10 +3557,16 @@ forms,
is preceded by
.BI { varname }
with no intervening space,
then a file descriptor number > 10
then a file descriptor number > 9
will be selected by
the shell and stored in the variable
.IR varname .
.IR varname ,
so it can be read from or written to with redirections like
.B <&
.I $varname
or
.B >&
.IR $varname .
If
.B >&\-
or the any of the