1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 19:52:20 +00:00
cde/TODO
Martijn Dekker 7003aba487 Fix 'test'/'[' exit status >1 on error in arithmetic expression
Fix BUG_TESTERR1A: POSIX non-compliance of 'test'/'[' exit status
on error. The command now returns status 2 instead of 1 when given
an invalid number or arithmetic expression, e.g.: [ 123 -eq 123x ]

The problem was that the test builtin (b_test()) calls the generic
arithmetic evaluation subsystem (sh/arith.c, sh/streval.c) which
has no awareness of the test builtin. A simple solution would be to
always make the arithmetic subsystem use an exit status > 1 for
arithmetic errors, but globally changing this may cause backwards
compatibility issues. So it's best to change the behaviour of the
'test' builtin only. This requires the arithmetic subsystem to be
aware of whether it was called from the 'test' builtin or not. To
that end, this commit adds a global flag and overrides the
ERROR_exit macro where needed.

src/cmd/ksh93/include/defs.h,
src/cmd/ksh93/sh/defs.c:
- Declare and initialise a global sh_in_test_builtin flag.
- Declare internal function for ERROR_exit override in test.c.

src/cmd/ksh93/bltins/test.c:
- Add override for ERROR_exit macro using a function that checks if
  the exit status is at least 2 if the error occurred while running
  the test builtin.
- b_test(): Set sh_in_test_builtin flag while running test builtin.

src/cmd/ksh93/sh/arith.c,
src/cmd/ksh93/sh/streval.c:
- Override ERROR_exit macro using function from test.c.

src/cmd/ksh93/tests/bracket.sh:
- Add regression test verifying status > 1 on arith error in test.

(cherry picked from commit 5eeae5eb9fd5ed961a5096764ad11ab870a223a9)
2020-06-12 01:45:15 +02:00

79 lines
3.8 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

TODO for AT&T ksh93, 93u+m bugfix branch
______
Fix or remove broken default aliases:
- Remove alias times='{ { time;} 2>&1;}' which does not produce POSIX-
compliant output; reimplement as a proper POSIX-compliant builtin.
In any case, implementing a standard utility as an alias is unacceptable
as 'unalias -a' (remove all aliases) should not remove standard utilities!
Backport the builtin from the abandoned Vashisht/Rader branch:
https://github.com/att/ast/pull/1332
- Remove alias command='command '. Continuing alias substitution after
'command' (due to the final space in the alias) is inherently broken, as
aliases may contain arbitrary shell grammar. For instance, when combining
this default alias with the default 'times' alias ('command times'), which
is perfectly valid per POSIX, you get a syntax error!
- Remove alias nohup='nohup '. Same reason as for 'command ' above.
- Remove pointless default aliases 'fc' and 'type'; these are already
implemented as normal shell builtins. Add man page entries for these.
______
Fix currently known bugs affecting shell scripting. These are identified by
their modernish IDs. For exact details, see code/comments in:
https://github.com/modernish/modernish/tree/0.16/lib/modernish/cap/
- BUG_BRACQUOT: shell quoting within bracket patterns has no effect. This
bug means the '-' retains it special meaning of 'character range', and an
initial ! (and, on some shells, ^) retains the meaning of negation, even
in quoted strings within bracket patterns, including quoted variables.
- BUG_CMDEXPAN: if the 'command' command results from an expansion, it acts
like 'command -v', showing the path of the command instead of executing it.
For example:
v=command; "$v" ls
or
set -- command ls; "$@"
don't work.
- BUG_CMDSPASGN: preceding a "special builtin"[*] with 'command' does not
stop preceding invocation-local variable assignments from becoming global.
[*] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14
- BUG_CMDSPEXIT: preceding a "special builtin"[*] (other than 'eval', 'exec',
'return' or 'exit') with 'command' does not always stop it from exiting
the shell if the builtin encounters error.
[*] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14
- BUG_CSUBSTDO: If standard output (file descriptor 1) is closed before
entering a $(command substitution), and any other file descriptors are
redirected within the command substitution, commands such as 'echo' will
not work within the command substitution, acting as if standard output is
still closed.
- BUG_IFSGLOBS: In glob pattern matching (as in case or parameter
substitution with # and %), if IFS starts with ? or * and the "$*"
parameter expansion inserts any IFS separator characters, those characters
are erroneously interpreted as wildcards when quoted "$*" is used as the
glob pattern.
- BUG_KUNSETIFS: ksh93: Can't unset IFS under very specific circumstances.
unset -v IFS is a known POSIX shell idiom to activate default field
splitting. With this bug, the unset builtin silently fails to unset IFS
(i.e. fails to activate field splitting) if we're executing an eval or a
trap and a number of specific conditions are met.
- BUG_LOOPRET2: If a 'return' command is given without a status argument
within the set of conditional commands in a 'while' or 'until' loop (i.e.,
between 'while'/'until' and 'do'), the exit status passed down from the
previous command is ignored and the function returns with status 0
instead.
- BUG_MULTIBIFS: We're on a UTF-8 locale and the shell supports UTF-8
characters in general (i.e. we don't have WRN_MULTIBYTE) however, using
multi-byte characters as IFS field delimiters still doesn't work. For
example, "$*" joins positional parameters on the first byte of IFS instead
of the first character.