1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Load 'r' and 'history' default aliases on interactive only

These two default aliases are useful on interactive shells. In
scripts, they interfere with possible function or command names.

As of this commit, these final two default aliases are only loaded
for interactive shells, leaving zero default aliases for scripts.
This completes the project to get rid of misguided default aliases.

src/cmd/ksh93/include/shtable.h,
src/cmd/ksh93/data/aliases.c:
src/cmd/ksh93/sh/init.c:
- Add empty alias table shtab_noaliases[] for scripts.
- Rename inittree() to sh_inittree() and make it external.
- nv_init(), sh_reinit(): Initialise empty alias tree for scripts.

src/cmd/ksh93/sh/main.c: sh_main():
- If interactive, reinitialise alias tree for interactive shells.

src/cmd/ksh93/tests/alias.sh:
- To test default alias removal, launch shell with -i.
This commit is contained in:
Martijn Dekker 2020-07-16 05:57:23 +01:00
parent a42ac7e77a
commit 17f81ebedb
7 changed files with 23 additions and 29 deletions

21
TODO
View file

@ -14,27 +14,6 @@ Fix build system:
to take effect. The machine-generated Mamfiles are now used as a fallback,
but they are not meant to be edited by hand.
______
Fix or remove broken or misguided default aliases:
- Make proper builtins out of the following scripting-related aliases, so
that 'unalias -a' does not eliminate them. If done correctly, this causes
no other change in behaviour. It would be good practice to 'unalias -a' in
a script to start with a clean slate, except ksh has always made that
impossible without losing these. Default aliases should be to facilitate
interactive use.
- autoload='typeset -fu'
- compound='typeset -C'
- float='typeset -lE'
- functions='typeset -f'
- integer='typeset -li'
- nameref='typeset -n'
Keep these default aliases for the benefit of interactive shells:
+ history='hist -l'
+ r='hist -s'
To avoid interfering with shell functions by those names that POSIX
scripts may set, those should only initialise on interactive shells.
______
Fix currently known bugs affecting shell scripting. These are identified by
their modernish IDs. For exact details, see code/comments in: