1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00
cde/src/cmd/ksh93/tests
Martijn Dekker e6d0187dd8 Don't allow 'enum' and 'typeset -T' to override special built-ins
Special builtins are undeleteable for a reason. But 'enum' and
'typeset -T' allow overriding them, causing an inconsistent state.

@JohnoKing writes:
| The behavior is rather buggy, as it appears to successfully
| override normal builtins but fails to delete the special
| builtins, leading to scenarios where both the original builtin
| and type are run:
|
| $ typeset -T eval=(typeset BAD; typeset TYPE)  # This should have failed
| $ eval foo=BAD
| /usr/bin/ksh: eval: line 1: foo: not found
| $ enum trap=(BAD TYPE)   # This also should have failed
| $ trap foo=BAD
| /usr/bin/ksh: trap: condition(s) required
| $ enum umask=(BAD TYPE)
| $ umask foo=BAD
| $ echo $foo
| BAD
|
| # Examples of general bugginess
| $ trap bar=TYPE
| /usr/bin/ksh: trap: condition(s) required
| $ echo $bar
| TYPE
| $ eval var=TYPE
| /usr/bin/ksh: eval: line 1: var: not found
| $ echo $var
| TYPE

This commit fixes the following:

The 'enum' and 'typeset -T' commands are no longer allowed to
override and replace special built-in commands, except for type
definition commands previously created by these commands; these
are already (dis)allowed elsewhere.

A command like 'typeset -T foo_t' without any assignments no longer
creates an incompletely defined 'foo_t' built-in comamnd. Instead,
it is now silently ignored for backwards compatibility. This did
have a regression test checking for it, but I'm changing it because
that's just not a valid use case. An incomplete type definition
command does nothing useful and only crashes the shell when run.

src/cmd/ksh93/bltins/enum.c: b_enum():
- Do not allow overriding non-type special built-ins.

src/cmd/ksh93/sh/name.c: nv_setlist():
- Do not allow 'typeset -T' to override non-type special built-ins.
  To avoid an inconsistent state, this must be checked for while
  processing the assignments list before typeset is really invoked.

src/cmd/ksh93/bltins_typeset.c: b_typeset():
- Only create a type command if sh.envlist is set, i.e., if some
  shell assignment(s) were passed to the 'typeset -T' command.

Progresses: https://github.com/ksh93/ksh/issues/350
2022-02-10 21:01:00 +00:00
..
_common tests/leaks.sh: redesign with a more robust testing algorithm 2021-12-28 17:47:29 +00:00
alias.sh Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
append.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
arith.sh Fix crash in xtrace while processing here-document (re: d7cada7b) 2021-12-27 04:02:25 +00:00
arrays.sh Fix conditional expansions ${array[i]=value}, ${array[i]?error} 2022-02-05 23:39:16 +00:00
arrays2.sh nv_associative(): finally use proper check for enum (re: b98e32fc) 2021-11-24 02:06:08 +01:00
attributes.sh Do not export variables with dot names (re: 8e72608c) 2022-02-05 15:08:50 +00:00
basic.sh Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
bracket.sh Accumulated fixes for minor issues (#442) 2022-01-30 20:42:59 +00:00
builtins.sh Accumulated fixes for minor issues (#442) 2022-01-30 20:42:59 +00:00
case.sh Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
comvar.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
comvario.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
coprocess.sh Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
cubetype.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
enum.sh Don't allow 'enum' and 'typeset -T' to override special built-ins 2022-02-10 21:01:00 +00:00
exit.sh Allow regression tests to pass without any /opt/ast/bin builtins (#403) 2021-12-28 17:52:57 +00:00
expand.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
functions.sh Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
glob.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
grep.sh Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
heredoc.sh Allow regression tests to pass without any /opt/ast/bin builtins (#403) 2021-12-28 17:52:57 +00:00
io.sh Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
jobs.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
leaks.sh tests/leaks.sh: add a newly discovered leak as known 2021-12-28 21:59:50 +00:00
locale.sh Allow regression tests to pass without any /opt/ast/bin builtins (#403) 2021-12-28 17:52:57 +00:00
math.sh Fix xtrace (shtests -x) for the regression tests 2021-05-14 19:56:11 +02:00
nameref.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
namespace.sh Export all variables assigned to while allexport is on (#431) 2022-02-05 13:52:28 +00:00
options.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
path.sh Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
pointtype.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
pty.sh Default to emacs upon invoking interactive shell 2022-02-01 23:47:56 +00:00
quoting.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
quoting2.sh Fix remaining bug in ${var:-'{}'} (re: d087b031) 2021-05-03 03:14:30 +01:00
readcsv.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
readonly.sh Adjust readonly regression tests for freezes (#267) 2021-04-11 19:57:40 +01:00
recttype.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
restricted.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
return.sh Fix crash in xtrace while processing here-document (re: d7cada7b) 2021-12-27 04:02:25 +00:00
select.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
shtests Some more accumulated minor tweaks and cleanups 2022-01-25 16:13:15 +00:00
sigchld.sh Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
signal.sh Fix SIGINT handling for external commands run from scripts 2022-02-01 05:50:10 +00:00
statics.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
subshell.sh Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
substring.sh Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
tilde.sh Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
timetype.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
treemove.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
types.sh Don't allow 'enum' and 'typeset -T' to override special built-ins 2022-02-10 21:01:00 +00:00
variables.sh Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
vartree1.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
vartree2.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00