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
|
@ -1478,7 +1478,7 @@ static Shnode_t *simple(Lex_t *lexp,int flag, struct ionod *io)
|
|||
if(nv_isattr(np,BLT_DCL))
|
||||
{
|
||||
assignment = 1;
|
||||
if(np==SYSTYPESET)
|
||||
if(np >= SYSTYPESET && np <= SYSTYPESET_END)
|
||||
lexp->intypeset = 1;
|
||||
key_on = 1;
|
||||
}
|
||||
|
@ -1517,7 +1517,9 @@ static Shnode_t *simple(Lex_t *lexp,int flag, struct ionod *io)
|
|||
int intypeset = lexp->intypeset;
|
||||
int type = 0;
|
||||
lexp->intypeset = 0;
|
||||
if(t->comnamp==SYSTYPESET)
|
||||
if(t->comnamp == SYSCOMPOUND)
|
||||
type = NV_COMVAR;
|
||||
else if((Namval_t*)t->comnamp >= SYSTYPESET && (Namval_t*)t->comnamp <= SYSTYPESET_END)
|
||||
{
|
||||
struct argnod *ap;
|
||||
for(ap=t->comarg->argnxt.ap;ap;ap=ap->argnxt.ap)
|
||||
|
|
|
@ -1295,20 +1295,21 @@ int sh_exec(register const Shnode_t *t, int flags)
|
|||
|
||||
}
|
||||
#endif /* SHOPT_BASH */
|
||||
if(np==SYSTYPESET || (np && np->nvalue.bfp==SYSTYPESET->nvalue.bfp))
|
||||
if(np && np->nvalue.bfp==SYSTYPESET->nvalue.bfp)
|
||||
{
|
||||
if(np!=SYSTYPESET)
|
||||
/* command calls b_typeset(); treat as a typeset variant */
|
||||
if(np < SYSTYPESET || np > SYSTYPESET_END)
|
||||
{
|
||||
shp->typeinit = np;
|
||||
tp = nv_type(np);
|
||||
}
|
||||
if(checkopt(com,'C'))
|
||||
if(np==SYSCOMPOUND || checkopt(com,'C'))
|
||||
flgs |= NV_COMVAR;
|
||||
if(checkopt(com,'S'))
|
||||
flgs |= NV_STATIC;
|
||||
if(checkopt(com,'m'))
|
||||
flgs |= NV_MOVE;
|
||||
if(checkopt(com,'n'))
|
||||
if(np==SYSNAMEREF || checkopt(com,'n'))
|
||||
flgs |= NV_NOREF;
|
||||
#if SHOPT_TYPEDEF
|
||||
else if(argn>=3 && checkopt(com,'T'))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue