[Perf] nvm_echo: use the printf shell builtin under zsh

In zsh, `command printf` skips the builtin and forks `/usr/bin/printf`.
This commit is contained in:
Cassidy Marble authored and Jordan Harband committed 2026-10-06 17:54:48 -03:00
1 parent 1dd1d8c82e
commit 66640e6000
2 files changed
+51 -2

No files matched your search

+13 -2
View File
@@ -22,11 +22,22 @@ nvm_stdout_is_terminal() {
}
nvm_echo() {
command printf %s\\n "$*" 2>/dev/null
# in zsh, `command printf` skips the builtin and runs `/usr/bin/printf`
if [ -n "${ZSH_VERSION-}" ]; then
# shellcheck disable=SC3044
builtin printf %s\\n "$*" 2>/dev/null
else
command printf %s\\n "$*" 2>/dev/null
fi
}
nvm_echo_with_colors() {
command printf %b\\n "$*" 2>/dev/null
if [ -n "${ZSH_VERSION-}" ]; then
# shellcheck disable=SC3044
builtin printf %b\\n "$*" 2>/dev/null
else
command printf %b\\n "$*" 2>/dev/null
fi
}
nvm_cd() {