[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:
Jordan Harband committed 2026-11-16 15:08:59 -08:00
1 parent 5671e688d2
commit f7280d116e
1 file changed
+7 -1
+7 -1
View File
@@ -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
}