mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Replace the hash alias with a proper builtin
This commit replaces the old hash alias with a proper builtin. I based this builtin off of the code alias uses for handling `alias -t --`, but with the hack for `--` removed as it has no use in the new builtin. `alias -t --` will no longer work, that hack is now gone. While I was testing this builtin, I found a bug with hash tables in non-forking subshells. If the hash table of a non-forking subshell is changed, the parent shell's hash table is also changed. As an example, running `(hash -r)` was resetting the parent shell's hash table. The workaround is to force the subshell to fork if the hash table will be changed. src/cmd/ksh93/bltins/typeset.c: - Move the code for hash out of the alias builtin into a dedicated hash builtin. `alias -t --` is no longer supported. src/cmd/ksh93/data/aliases.c: - Remove the old alias for hash from the table of predefined aliases. src/cmd/ksh93/data/builtins.c: - Fix the broken entry for the hash builtin and add a man page for the new builtin. src/cmd/ksh93/sh.1: - Replace the entry for the hash alias with a more detailed entry for the hash builtin. src/cmd/ksh93/sh/name.c: - Force non-forking subshells to fork if the PATH is being reset to workaround a bug with the hash tree. src/cmd/ksh93/tests/alias.sh: - Add a regression test for resetting a hash table, then adding a utility to the refreshed hash table. src/cmd/ksh93/tests/subshell.sh: - Add regression tests for changing the hash table in subshells. (cherry picked from commit d8428a833afe9270b61745ba3d6df355fe1d5499)
This commit is contained in:
parent
d1bd8f89b7
commit
102868f850
10 changed files with 121 additions and 32 deletions
|
@ -796,8 +796,6 @@ but can be unset or redefined:
|
|||
.TP
|
||||
.B "functions=\(fmtypeset \-f\(fm"
|
||||
.TP
|
||||
.B "hash=\(fmalias \-t \-\^\-\(fm"
|
||||
.TP
|
||||
.B "history=\(fmhist \-l\(fm"
|
||||
.TP
|
||||
.B "integer=\(fmtypeset \-li\(fm"
|
||||
|
@ -6126,6 +6124,21 @@ The option
|
|||
.B #
|
||||
can only be specified as the first option.
|
||||
.TP
|
||||
\f3hash\fP \*(OK \f3\-r\fP \f2\^\fP\*(CK \*(OK \f3utility\^\fP \*(CK
|
||||
The
|
||||
.BR hash
|
||||
command can be used to display or modify the hash table.
|
||||
The hash table is a list of the most recently used programs
|
||||
and their locations.
|
||||
If
|
||||
.I utility\^
|
||||
is supplied,
|
||||
.BR hash
|
||||
will add that utility to the hash table.
|
||||
If
|
||||
.B \-r
|
||||
is selected, the hash table is reset.
|
||||
.TP
|
||||
.PD 0
|
||||
\f3hist\fP \*(OK \f3\-e\fP \f2ename\^\fP \ \*(CK \*(OK \f3\-nlr\^\fP \*(CK \*(OK \f2first\^\fP \*(OK \f2last\^\fP \*(CK \*(CK
|
||||
.TP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue