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

Fix 'command -p' by fixing initialisation of default PATH variable

'command -p' was broken for non-interactive shells as the variable
used to store the default system PATH, std_path, was not
initialised correctly. For instance:
	$ ksh -c 'command -p ls'
	ksh: ls: not found
This fix by Siteshwar Vashisht is backported from ksh2020.
Ref.:
https://github.com/att/ast/issues/426
https://github.com/att/ast/pull/448

src/cmd/ksh93/sh/path.c:
- Correctly initialise std_path (the default PATH) when ksh is
  started as a non-interactive shell.

src/cmd/ksh93/sh.1:
- Fix vague explanation of 'command -p'.

src/cmd/ksh93/tests/path.sh:
- Add regression test.

(cherry picked from commit a76439d60b70c18cf44d84c1962fcd8df84c947c)
This commit is contained in:
Martijn Dekker 2020-05-19 15:49:56 +01:00
parent f35e7ecd1d
commit c9ccee86bb
5 changed files with 24 additions and 7 deletions

View file

@ -397,5 +397,11 @@ ${.sh.version}
END
) || err_exit '${.sh.xxx} variables causes cat not be found'
# ======
# Check that 'command -p' searches the default OS utility PATH.
v=$(PATH=/dev/null "$SHELL" -c 'command -p ls /dev/null')
[[ $v == /dev/null ]] || err_exit 'command -p fails to find standard utility'
# ======
exit $((Errors<125?Errors:125))