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

Disallow >;word and <>;word for 'redirect' (re: 7b59fb80, 7b82c338)

The >;word and <>;word redirection operators cannot be used with
the 'exec' builtin, but the 'redirect' builtin (which used to be
an alias of 'command exec') permitted them. However, they do not
have the documented effect of the added ';'. So this commit blocks
those operators for 'redirect' as they are blocked for 'exec'.

It also tweaks redirect's error message if a non-redirection
argument is encountered.

src/cmd/ksh93/sh/parse.c: simple():
- Set the lexp->inexec flag for SYSREDIR (redirect) as well as
  SYSEXEC (exec). This flag is checked for in sh_lex() (lex.c) to
  throw a syntax error if one of these two operators is used.

src/cmd/ksh93/sh.1, src/cmd/ksh93/data/builtins.c:
- Documentation tweaks.

src/cmd/ksh93/sh/xec.c, src/cmd/ksh93/bltins/misc.c:
- When 'redirect' gives an 'incorrect syntax' (e_badsyntax) error
  message, include the first word that was found not to be a valid
  redirection. This is simply the first argument, as redirections
  are removed from the arguments list.

src/cmd/ksh93/tests/io.sh:
- Update test to reflect new error message format.
This commit is contained in:
Martijn Dekker 2021-02-06 22:00:55 +00:00
parent 43dfe3c8fa
commit 403e864ac8
6 changed files with 21 additions and 15 deletions

View file

@ -3403,7 +3403,9 @@ otherwise, delete the temporary file.
.BI >; word
cannot be used with the
.IR exec
built-in.
and
.IR redirect
built-ins.
.TP
.BI >> word
Use file
@ -3428,7 +3430,9 @@ is truncated to the offset at command completion.
.BI <>; word
cannot be used with the
.IR exec
built-in.
and
.IR redirect
built-ins.
.TP
\f3<<\fP\*(OK\f3\-\fP\*(CK\f2word\fP
The shell input is read up to a line that is the same as
@ -6854,11 +6858,11 @@ section above),
with the difference that the effect persists past the execution of the
.B redirect
command.
Any file descriptor numbers greater than
When invoking another program, file descriptors greater than
.B 2
that are opened with this mechanism are closed when invoking another program,
unless they are explicitly redirected to themselves as part of that invocation
(e.g. \fB4>&4\fR) or the \fBposix\fR shell option is active.
that were opened with this mechanism are only passed on if they are explicitly
redirected to themselves as part of the invocation (e.g. \fB4>&4\fR)
or if the \fBposix\fR option is set.
.TP
\(dg \f3return\fP \*(OK \f2n\^\fP \*(CK
Causes a shell