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
|
@ -26,23 +26,31 @@
|
|||
#include "FEATURE/dynamic"
|
||||
#include "shtable.h"
|
||||
|
||||
#define SYSLOGIN (shgd->bltin_cmds)
|
||||
#define SYSEXEC (shgd->bltin_cmds+1)
|
||||
#define SYSSET (shgd->bltin_cmds+2)
|
||||
#define SYSTRUE (shgd->bltin_cmds+4)
|
||||
#define SYSCOMMAND (shgd->bltin_cmds+5)
|
||||
#define SYSCD (shgd->bltin_cmds+6)
|
||||
#define SYSBREAK (shgd->bltin_cmds+7)
|
||||
#define SYSCONT (shgd->bltin_cmds+8)
|
||||
#define SYSTYPESET (shgd->bltin_cmds+9)
|
||||
#define SYSTEST (shgd->bltin_cmds+10)
|
||||
#define SYSBRACKET (shgd->bltin_cmds+11)
|
||||
#define SYSLET (shgd->bltin_cmds+12)
|
||||
#define SYSEXPORT (shgd->bltin_cmds+13)
|
||||
#define SYSDOT (shgd->bltin_cmds+14)
|
||||
#define SYSRETURN (shgd->bltin_cmds+15)
|
||||
/*
|
||||
* IDs for the parser (parse.c) and parse tree executer (xec.c)
|
||||
* to implement special handling for the corresponding builtins.
|
||||
* IMPORTANT: The offsets on these macros must be synchronous
|
||||
* with the order of shtab_builtins[] in data/builtins.c!
|
||||
*/
|
||||
#define SYSLOGIN (shgd->bltin_cmds) /* login */
|
||||
#define SYSEXEC (shgd->bltin_cmds+1) /* exec */
|
||||
#define SYSREDIR (shgd->bltin_cmds+2) /* redirect */
|
||||
#define SYSSET (shgd->bltin_cmds+3) /* set */
|
||||
/* : */
|
||||
#define SYSTRUE (shgd->bltin_cmds+5) /* true */
|
||||
#define SYSCOMMAND (shgd->bltin_cmds+6) /* command */
|
||||
#define SYSCD (shgd->bltin_cmds+7) /* cd */
|
||||
#define SYSBREAK (shgd->bltin_cmds+8) /* break */
|
||||
#define SYSCONT (shgd->bltin_cmds+9) /* continue */
|
||||
#define SYSTYPESET (shgd->bltin_cmds+10) /* typeset */
|
||||
#define SYSTEST (shgd->bltin_cmds+11) /* test */
|
||||
#define SYSBRACKET (shgd->bltin_cmds+12) /* [ */
|
||||
#define SYSLET (shgd->bltin_cmds+13) /* let */
|
||||
#define SYSEXPORT (shgd->bltin_cmds+14) /* export */
|
||||
#define SYSDOT (shgd->bltin_cmds+15) /* . */
|
||||
#define SYSRETURN (shgd->bltin_cmds+16) /* return */
|
||||
#if SHOPT_BASH
|
||||
# define SYSLOCAL (shgd->bltin_cmds+16)
|
||||
# define SYSLOCAL (shgd->bltin_cmds+17) /* local */
|
||||
#else
|
||||
# define SYSLOCAL 0
|
||||
#endif
|
||||
|
@ -153,6 +161,7 @@ extern const char sh_optdot[];
|
|||
#endif /* !ECHOPRINT */
|
||||
extern const char sh_opteval[];
|
||||
extern const char sh_optexec[];
|
||||
extern const char sh_optredirect[];
|
||||
extern const char sh_optexit[];
|
||||
extern const char sh_optexport[];
|
||||
extern const char sh_optgetopts[];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue