1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 03:32:24 +00:00

Fix BUG_REDIRIO

ksh used to redirect standard output by default when no file
descriptor was specified with the rarely used '<>' reading/writing
redirection operator. It now redirects standard input by default,
as POSIX specifies and as all other POSIX shells do. To redirect
standard output for reading and writing, you now need '1<>'.

Ref.: https://github.com/att/ast/issues/75
      http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_07

(cherry picked from commit 29afc16c47824fc79ed092ae7704c525b1db6a0a)
This commit is contained in:
Martijn Dekker 2020-05-13 15:00:33 +01:00
parent 915b2b2e19
commit eeee77edd1
4 changed files with 11 additions and 8 deletions

9
NEWS
View file

@ -23,3 +23,12 @@ Any uppercase BUG_* names are modernish shell bug IDs.
case $n in
( [0-9] | "[0-9]") echo "$n is a number or the number pattern" ;;
esac
Ref.: https://github.com/att/ast/issues/476
- Fix BUG_REDIRIO: ksh used to redirect standard output by default when no
file descriptor was specified with the rarely used '<>' reading/writing
redirection operator. It now redirects standard input by default, as POSIX
specifies and as all other POSIX shells do. To redirect standard output
for reading and writing, you now need '1<>'.
Ref.: https://github.com/att/ast/issues/75
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_07

6
TODO
View file

@ -75,11 +75,5 @@ https://github.com/modernish/modernish/tree/0.16/lib/modernish/cap/
on output. This means a script cannot check for them, and a script process
in a pipe can get stuck in an infinite loop if SIGPIPE is ignored.
- BUG_REDIRIO: the I/O redirection operator <> (open a file descriptor for
both read and write) defaults to opening standard output (i.e. is short
for 1<>) instead of defaulting to opening standard input (0<>) as POSIX
specifies[*].
[*] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_07
- BUG_TESTERR1A: test/[ exits with a non-error false status (1) if an
invalid argument is given to an operator.

View file

@ -3459,7 +3459,7 @@ otherwise, the file is created.
Open file
.I word\^
for reading and writing
as standard output.
as standard input.
.TP
.BI <>; word
The same as

View file

@ -599,7 +599,7 @@ int sh_lex(Lex_t* lp)
c |= SYMPIPE;
else if(c=='<' && n=='>')
{
lp->digits = 1;
lp->digits = 0;
c = IORDWRSYM;
fcgetc(n);
if(fcgetc(n)==';')