mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix 'whence -a' to print correct path for tracked alias (#25)
'whence -a' bases the path for tracked aliases on the user's current working directory if an enabled ksh builtin of the same name is also available. The following example will claim 'cat' is in the user's current working directory: $ whence -a cat cat is a tracked alias for /usr/bin/cat $ builtin cat $ whence -a cat cat is a shell builtin cat is /usr/bin/cat cat is a tracked alias for /current/working/directory/cat This patch from ksh2020 fixes this problem by properly saving the path of the tracked alias for use with 'whence -a', since 'path_pwd' (as implied by the function's name) only gets the users current working directory, not the location of tracked aliases. Ref.: https://github.com/att/ast/issues/1049 This bug was originally reported by David Morano about two decades ago to the AST team: https://github.com/att/ast/issues/954 src/cmd/ksh93/bltins/whence.c: - Print the actual path of a tracked alias, path_pwd doesn't have this functionality. src/cmd/ksh93/include/name.h: - Add 'pathcomp' for saving the value of tracked aliases. src/cmd/ksh93/sh/path.c: - Save the value of tracked aliases for use by whence. src/cmd/ksh93/tests/builtins.sh: - Add a regression test for using 'whence -a' on tracked aliases with a builtin equivalent.
This commit is contained in:
parent
876da711c0
commit
99065353b3
6 changed files with 30 additions and 2 deletions
|
@ -702,5 +702,19 @@ printf '\\\000' | read -r -d ''
|
|||
foo=BUG command eval ':'
|
||||
[[ $foo == BUG ]] && err_exit '`command` fails to disable the special properties of special builtins'
|
||||
|
||||
# ======
|
||||
# `whence -a` should not base the path of tracked aliases on the current directory
|
||||
run_whence()
|
||||
{
|
||||
whence -a chmod >> /dev/null
|
||||
builtin chmod
|
||||
whence -a chmod
|
||||
}
|
||||
actual="$(run_whence)"
|
||||
expected="chmod is a shell builtin
|
||||
chmod is $(whence -p chmod)
|
||||
chmod is a tracked alias for $(whence -p chmod)"
|
||||
[[ $actual == $expected ]] || err_exit '`whence -a` does not work correctly with tracked aliases'
|
||||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue