-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the 'history' and 'r' commands builtins #76
Conversation
With this change no more preset aliases exist, so the preset alias tables can be safely removed. All ksh commands can now be used without 'unalias -a' removing them, even in interactive shells. Additionally, the history and r commands are no longer limited to being used in interactive shells. src/cmd/ksh93/bltins/hist.c: - Implement the history and r commands as builtins. Also guarantee lflag is set to one by avoiding 'lflag++'. src/cmd/ksh93/Makefile, src/cmd/ksh93/Mamfile, src/cmd/ksh93/sh/main.c, src/cmd/ksh93/sh/init.c, src/cmd/ksh93/data/aliases.c: - Remove the table of predefined aliases because the last few have been removed. During init the alias tree is now initialized the same way as the function tree, rather than with a dummy shell table. src/cmd/ksh93/bltins/typeset.c: - Remove the now bugfix for unsetting predefined aliases because it is now a no-op. Aliases are no longer able to have the NV_NOFREE attribute. src/cmd/ksh93/tests/alias.sh: - Remove the regression test for unsetting predefined aliases since those no longer exist. src/cmd/ksh93/sh.1: - Remove the list of preset aliases since those no longer exist. - Document history and r as builtins instead of preset aliases.
Are there actually scripts that use these? |
I'm not sure about |
True. My assumption was that no existing .kshrc is going to run OTOH, your approach makes everything consistent and simplifies the code, and that is good. And your way of initialising an empty alias table is clearly better. I have a couple of tweaks (particularly |
This is just to avoid hard-to-read diffs when comparing across multiple commits. src/cmd/ksh93/sh/init.c: - Rename sh_inittree() back to inittree(). - nv_init(): Move alias_tree init to same line as before.
27cd3fe
to
eb980aa
Compare
@JohnoKing @McDutchie: |
|
Excellent. Thank you! |
This pull request makes
history
andr
commands builtins that aren't limited to interactive shells. All ksh commands can now be used withoutunalias -a
removing them (unalias -a
in.kshrc
no longer removeshistory
andr
). With this change no more preset aliases exist, so the preset alias tables can be safely removed. The alias tree is now initialized in the same way as the function tree:ksh/src/cmd/ksh93/sh/init.c
Line 1858 in 17f81eb
The
sh_inittree
code for comparison:ksh/src/cmd/ksh93/sh/init.c
Line 1900 in 17f81eb