[Fix] nvm_process_nvmrc_content: a key containing a space is not a duplicate of each word in it

The duplicate-key check kept keys in a space-separated list,
so a key such as `a b` followed by a key `a` or `b` was reported as a duplicate,
unlike in the `nvmrc` package.
Keep the keys newline-separated, since a key cannot contain a newline.
This commit is contained in:
Jordan Harband committed 2026-11-18 16:20:53 -08:00
1 parent e8cfc3975d
commit 944232943b
2 files changed
+10 -5

No files matched your search

+9 -4
View File
@@ -1082,14 +1082,19 @@ nvm_process_nvmrc_content() {
fi fi
# Check for duplicate keys, in the shell: a symlinked `.nvmrc` can hold any file's content, # Check for duplicate keys, in the shell: a symlinked `.nvmrc` can hold any file's content,
# and every local user can read a process's arguments # and every local user can read a process's arguments.
case "${keys} " in # Keys are newline-separated, since a key can contain a space but not a newline.
*" ${key} "*) case "${keys}
" in
*"
${key}
"*)
nvm_nvmrc_invalid_msg "${lines}" nvm_nvmrc_invalid_msg "${lines}"
return 1 return 1
;; ;;
esac esac
keys="${keys} ${key}" keys="${keys}
${key}"
values="${values} ${value}" values="${values} ${value}"
else else
if [ -n "${unpaired_line}" ]; then if [ -n "${unpaired_line}" ]; then
@@ -25,7 +25,7 @@ ${KEY} = 3"
done done
# keys are compared as they are written, not as patterns # keys are compared as they are written, not as patterns
for KEY in b ab A a. '*' '.*' '?' 'a|b' '[a]'; do for KEY in b ab A a. '*' '.*' '?' 'a|b' '[a]' 'a b' 'b a' 'b a'; do
for CONTENT in "20 for CONTENT in "20
a=1 a=1
${KEY}=2" "20 ${KEY}=2" "20