mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Make 'redirect' a regular builtin instead of an alias of 'exec'
This commit converts the redirect='command exec' alias to a regular 'redirect' builtin command that only accepts I/O redirections, which persist as in 'exec'. This means that: * 'unlias -a' no longer removes the 'redirect' command; * users no longer accidentally get logged out of their shells if they type something intuitive but wrong, like 'redirect ls >file'. This should not introduce any legitimate change in behaviour. If someone did accidentally pass non-redirection arguments to 'redirect', unexpected behaviour would occur; this now produces an 'incorrect syntax' error. src/cmd/ksh93/bltins/misc.c: b_exec(): - Recognise 'redirect' when parsing options. - If invoked as 'redirect', produce error if there are arguments. src/cmd/ksh93/data/aliases.c: - Remove redirect='command exec' alias. src/cmd/ksh93/data/builtins.c: - Update/improve comments re ordering. - Add 'redirect' builtin entry. - sh_optexec[]: Abbreviate redirection-related documentation; refer to redirect(1) instead. - sh_optredirect[]: Add documentation. src/cmd/ksh93/include/builtins.h: - Add SYSREDIR parser ID, renumbering those following it. - Improve comments. - Add extern sh_optredirect[]. src/cmd/ksh93/sh.1: - exec: Abbreviate redirection-related documentation; refer to 'redirect' instead. - redirect: Add documentation. src/cmd/ksh93/sh/xec.c: - Recognise SYSREDIR parser ID in addition to SYSEXEC when determining whether to make redirections persistent. src/cmd/ksh93/tests/io.sh: - To regress-test the new builtin, change most 'command exec' uses to 'redirect'. - Add tests verifying the exit behaviour of 'exec', 'command exec', 'redirect' on redirections.
This commit is contained in:
parent
936802f92a
commit
7b82c338da
9 changed files with 134 additions and 75 deletions
|
@ -1334,8 +1334,8 @@ int sh_exec(register const Shnode_t *t, int flags)
|
|||
struct openlist *item;
|
||||
if(np==SYSLOGIN)
|
||||
type=1;
|
||||
else if(np==SYSEXEC)
|
||||
type=1+!com[1];
|
||||
else if(np==SYSEXEC || np==SYSREDIR) /* 'exec' or 'redirect' */
|
||||
type=1+!com[1]; /* redirections persist if no args */
|
||||
else
|
||||
type = (execflg && !shp->subshell && !shp->st.trapcom[0]);
|
||||
shp->redir0 = 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue