[Fix] nvm_echo: in pdksh and mksh, use print, not /usr/bin/printf
pdksh (OpenBSD's `/bin/sh`) and mksh have no `printf` builtin, so every `nvm_echo` ran `/usr/bin/printf` with its text as an argument, which every local user can read (`ps`, `/proc/<pid>/cmdline`). That text includes a symlinked `.nvmrc`'s content while it is parsed, so these shells still exposed it after 3a6403f9.
This commit is contained in:
1 file changed
+7
-1
@@ -24,7 +24,13 @@ nvm_echo() {
|
||||
# shellcheck disable=SC3044
|
||||
builtin printf %s\\n "$*" 2>/dev/null
|
||||
else
|
||||
command printf %s\\n "$*" 2>/dev/null
|
||||
case "${KSH_VERSION-}" in
|
||||
# pdksh and mksh have no `printf` builtin; `/usr/bin/printf` would put the text in its arguments
|
||||
*'PD KSH'* | *'MIRBSD KSH'* | *'LEGACY KSH'*)
|
||||
print -r -- "$*" 2>/dev/null
|
||||
;;
|
||||
*) command printf %s\\n "$*" 2>/dev/null ;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user