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

-o posix: always recognise octals in "let" builtin

Though the "let" builtin is not itself a POSIX standard command, it
processes standard shell arithmetic, so it should recognise octals
by leading zeros as POSIX requires if the 'posix' option is on.
This overrides the setting of the 'letoctal' option.

Note that none of this applies to the ((...)) arithmetic command,
which has always recognised leading-octal zeros and does not listen
to 'letoctal'. So setting the posix mode makes this consistent.

src/cmd/ksh93/sh/arith.c:
- When running the 'let' builtin, test that both SH_LETOCTAL and
  SH_POSIX are off before stripping leading zeros to disable octal
  number recognition.
- Cosmetic: fix spurious newline.

src/cmd/ksh93/sh.1:
- Document the change.

src/cmd/ksh93/tests/shtests:
- Make sure to disable posix mode by default for regression tests.
This commit is contained in:
Martijn Dekker 2020-09-01 07:16:51 +01:00
parent 921bbcaeb7
commit b301d41731
5 changed files with 19 additions and 10 deletions

View file

@ -680,9 +680,8 @@ exp='typeset -C -a x=((typeset -C -a y=( [0]=(typeset -a -l -i z=([2]=3);));))'
unset x
let x=010
[[ $x == 10 ]] || err_exit 'let treating 010 as octal'
set -o letoctal
let x=010
[[ $x == 8 ]] || err_exit 'let not treating 010 as octal with letoctal on'
(set -o letoctal; let x=010; [[ $x == 8 ]]) || err_exit 'let not treating 010 as octal with letoctal on'
(set -o posix 2>/dev/null; let x=010; [[ $x == 8 ]]) || err_exit 'let not treating 010 as octal with posix on'
float z=0
integer aa=2 a=1

View file

@ -166,7 +166,8 @@ function valxml
return $errors
}
unset DISPLAY FIGNORE HISTFILE
command set +o posix 2>/dev/null
unset DISPLAY FIGNORE HISTFILE POSIXLY_CORRECT _AST_FEATURES
export ENV=/./dev/null
trap + PIPE # unadvertized -- set SIGPIPE to SIG_DFL #