mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Convert default typeset aliases to regular builtins
This converts the 'autoload', 'compound', 'float', 'functions', 'integer' and 'nameref' default aliases into regular built-in commands, so that 'unalias -a' does not remove them. Shell functions can now use these names, which improves compatibility with POSIX shell scripts. src/cmd/ksh93/data/aliases.c: - Remove default typeset aliases. src/cmd/ksh93/data/builtins.c, src/cmd/ksh93/include/builtins.h: - Add corresponding built-in command declarations. Typeset-style commands are now defined by a pointer range, SYSTYPESET .. SYSTYPESET_END. A couple need their own IDs (SYSCOMPOUND, SYSNAMEREF) for special-casing in sh/xec.c. - Update 'typeset --man'. src/cmd/ksh93/bltins/typeset.c: b_typeset(): - Recognise the new builtin commands by argv[0]. Implement them by inserting the corresponding 'typeset' options into the argument list before parsing options. This may seem like a bit of a hack, but it is simpler, shorter, more future-proof and less error-prone than manually copying and adapting all the complex flaggery from the option parsing loop. src/cmd/ksh93/sh/parse.c, src/cmd/ksh93/sh/xec.c: - Recognise typeset-style commands by SYSTYPESET .. SYSTYPESET_END pointer range. - Special-case 'compound' (SYSCOMPOUND) and 'nameref' (SYSNAMEREF) along with recognising the corresponding 'typeset' options. src/cmd/ksh93/sh.1: - Update to document the new built-ins. - Since not all declaration commands are special built-ins now, identify declaration commands using a double-dagger "\(dd" character (which renders as '=' in ASCII) and disassociate their definition from that of special built-ins. src/cmd/ksh93/tests/variables.sh: - Adapt a regression test as there is no more 'integer' alias.
This commit is contained in:
parent
45cfecfc1e
commit
1fbbeaa19d
10 changed files with 129 additions and 65 deletions
|
@ -41,16 +41,25 @@
|
|||
#define SYSCD (shgd->bltin_cmds+6) /* cd */
|
||||
#define SYSBREAK (shgd->bltin_cmds+7) /* break */
|
||||
#define SYSCONT (shgd->bltin_cmds+8) /* continue */
|
||||
#define SYSTYPESET (shgd->bltin_cmds+9) /* typeset */
|
||||
#define SYSTEST (shgd->bltin_cmds+10) /* test */
|
||||
#define SYSBRACKET (shgd->bltin_cmds+11) /* [ */
|
||||
#define SYSLET (shgd->bltin_cmds+12) /* let */
|
||||
#define SYSEXPORT (shgd->bltin_cmds+13) /* export */
|
||||
#define SYSDOT (shgd->bltin_cmds+14) /* . */
|
||||
#define SYSSOURCE (shgd->bltin_cmds+15) /* source */
|
||||
#define SYSRETURN (shgd->bltin_cmds+16) /* return */
|
||||
|
||||
#define SYSTYPESET (shgd->bltin_cmds+9) /* typeset \ */
|
||||
/* autoload | */
|
||||
#define SYSCOMPOUND (shgd->bltin_cmds+11) /* compound | */
|
||||
/* float >typeset range */
|
||||
/* functions | */
|
||||
/* integer | */
|
||||
#define SYSNAMEREF (shgd->bltin_cmds+15) /* nameref | */
|
||||
#define SYSTYPESET_END (shgd->bltin_cmds+15) /* / */
|
||||
|
||||
#define SYSTEST (shgd->bltin_cmds+16) /* test */
|
||||
#define SYSBRACKET (shgd->bltin_cmds+17) /* [ */
|
||||
#define SYSLET (shgd->bltin_cmds+18) /* let */
|
||||
#define SYSEXPORT (shgd->bltin_cmds+19) /* export */
|
||||
#define SYSDOT (shgd->bltin_cmds+20) /* . */
|
||||
#define SYSSOURCE (shgd->bltin_cmds+21) /* source */
|
||||
#define SYSRETURN (shgd->bltin_cmds+22) /* return */
|
||||
#if SHOPT_BASH
|
||||
# define SYSLOCAL (shgd->bltin_cmds+17) /* local */
|
||||
# define SYSLOCAL (shgd->bltin_cmds+23) /* local */
|
||||
#else
|
||||
# define SYSLOCAL 0
|
||||
#endif
|
||||
|
|
|
@ -17,4 +17,4 @@
|
|||
* David Korn <dgk@research.att.com> *
|
||||
* *
|
||||
***********************************************************************/
|
||||
#define SH_RELEASE "93u+m 2020-07-14"
|
||||
#define SH_RELEASE "93u+m 2020-07-15"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue