1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-25 08:34:36 +00:00
cde/src/cmd/ksh93/tests
Martijn Dekker b9d10c5a9c Fix 'command' expansion bug and POSIX compliance
The 'command' name can now result from an expansion, e.g.:
	c=command; "$c" ls
	set -- command ls; "$@"
both work now. This fixes BUG_CMDEXPAN.

If -o posix is on, 'command' now disables not only the "special"
but also the "declaration" properties of builtin commands that it
invokes. This is because POSIX specifies 'command' as a simple
regular builtin, and any command name following 'command' is just
an argument to the 'command' command, so there is nothing that
allows any further arguments (such as assignment-arguments) to be
treated specially by the parser. So, if and only if -o posix is on:
a. Arguments that start with a variable name followed by '=' are
   always treated as regular words subject to normal shell syntax.
b. Since assignment-arguments are not processed as assignments
   before the command itself, 'command' can now stop the shell from
   exiting (as required by the standard) if a command that it
   invokes (such as 'export') tries to modify a readonly variable.
   This fixes BUG_CMDSPEXIT.

Most of 'command' is integrated in the parser and parse tree
executer, so that is where it needed fixing.

src/cmd/ksh93/sh/parse.c: simple():
- If the posix option is on, do not skip past SYSCOMMAND so that
  any declaration builtin commands that are arguments to 'command'
  are not detected and thus not treated specially at parsetime.

src/cmd/ksh93/sh/xec.c: sh_exec():
- When detecting SYSCOMMAND in order to skip past it, not only
  compare the Namval_t pointer 'np' to SYSCOMMAND, but also handle
  the case where that pointer is NULL, as when the command name
  results from an expansion. In that case, search the function tree
  shp->fun_tree for the name and see if that yields the SYSCOMMAND
  pointer. fun_tree is initialised with a dtview to bltin_tree, so
  searching fun_tree instead allows for overriding 'command' with a
  shell function (which the POSIX standard requires us to allow).

src/cmd/ksh93/sh.1,
src/cmd/ksh93/data/builtins.c:
- Update documentation to match these changes.
- Various related edits and improvements.

src/cmd/ksh93/tests/builtins.sh:
- Check that 'command' works if resulting from an expansion.
- Check that 'command' can be overridden by a shell function.
2020-09-11 10:06:43 +02:00
..
alias.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
append.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
arith.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
arrays.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
arrays2.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
attributes.sh -o posix: don't import/export variable attributes thru environment 2020-09-05 11:41:02 +02:00
basic.sh Fix BUG_LOOPRET2 and related return/exit misbehaviour 2020-09-09 20:02:20 +02:00
bracket.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
builtins.sh Fix 'command' expansion bug and POSIX compliance 2020-09-11 10:06:43 +02:00
case.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
comvar.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
comvario.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
coprocess.sh tests/coprocess.sh: fix rare fail (re: 712261c8) 2020-09-06 22:40:17 +02:00
cubetype.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
enum.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
exit.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
expand.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
functions.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
glob.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
grep.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
heredoc.sh Fix ${!} and ${$} throwing syntax error in here-document 2020-09-04 04:54:35 +02:00
io.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
leaks.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
locale.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
math.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
nameref.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
namespace.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
options.sh fix "$-" expansion for posix option (re: 921bbcae) 2020-09-04 21:03:28 +02:00
path.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
pointtype.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
pty.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
quoting.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
quoting2.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
readcsv.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
recttype.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
restricted.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
return.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
select.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
shtests shtests: add ${.sh.pid} to PS4/xtrace (re: 9de65210) 2020-09-02 15:51:02 +01:00
sigchld.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
signal.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
statics.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
subshell.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
substring.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
tilde.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
timetype.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
treemove.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
types.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
variables.sh Fix subshell leak for 3 special variables (re: 417883df, bd3e2a80) 2020-09-05 20:47:03 +02:00
vartree1.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00
vartree2.sh shtests: cd to each test set's temp dir before running 2020-09-02 06:02:40 +01:00