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
|
@ -496,8 +496,9 @@ chmod +x $tmp/script
|
|||
)
|
||||
TIMEFORMAT='this is a test'
|
||||
[[ $(set +x; { { time :;} 2>&1;}) == "$TIMEFORMAT" ]] || err_exit 'TIMEFORMAT not working'
|
||||
alias _test_alias=true
|
||||
: ${.sh.version}
|
||||
[[ $(alias integer) == *.sh.* ]] && err_exit '.sh. prefixed to alias name'
|
||||
[[ $(alias _test_alias) == *.sh.* ]] && err_exit '.sh. prefixed to alias name'
|
||||
: ${.sh.version}
|
||||
[[ $(whence rm) == *.sh.* ]] && err_exit '.sh. prefixed to tracked alias name'
|
||||
: ${.sh.version}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue