[Fix] nvm_resolve_local_alias: avoid using variable as printf format string

Using a variable as the format string means `%` characters in alias names would be interpreted as format specifiers.
Use `%b` format with the variable as an argument to safely interpret `\n` escapes.

Bug introduced in https://github.com/nvm-sh/nvm/commit/9b91734f0b6a210f0c6655b0cd25ea288d9ae376.
This commit is contained in:
Jordan Harband committed 2026-03-14 10:16:25 -07:00
1 parent 3c48015986
commit d2fca5f0ec
5 files changed
+43 -1

No files matched your search

+1 -1
View File
@@ -1368,7 +1368,7 @@ nvm_resolve_alias() {
break
fi
if command printf "${SEEN_ALIASES}" | nvm_grep -q -e "^${ALIAS_TEMP}$"; then
if command printf '%b' "${SEEN_ALIASES}" | nvm_grep -q -e "^${ALIAS_TEMP}$"; then
ALIAS="∞"
break
fi