[Fix] nvm_get_default_packages: use portable awk patterns

Replace POSIX `[[:space:]]` character class with `[ \t]` for
mawk compatibility on Ubuntu 16.04.
This commit is contained in:
Jordan Harband
2026-01-26 16:59:11 -08:00
parent aa1d829102
commit 38ffc713a7
2 changed files with 60 additions and 3 deletions

6
nvm.sh
View File

@@ -4530,9 +4530,9 @@ nvm_get_default_packages() {
NVM_DEFAULT_PACKAGE_FILE="${NVM_DIR}/default-packages"
if [ -f "${NVM_DEFAULT_PACKAGE_FILE}" ]; then
command awk -v filename="${NVM_DEFAULT_PACKAGE_FILE}" '
/^[[:space:]]*#/ { next } # Skip lines that begin with #
/^[[:space:]]*$/ { next } # Skip empty lines
/[[:space:]]/ && !/^[[:space:]]*#/ {
/^[ \t]*#/ { next } # Skip lines that begin with #
/^[ \t]*$/ { next } # Skip empty lines
/[ \t]/ && !/^[ \t]*#/ {
print "Only one package per line is allowed in `" filename "`. Please remove any lines with multiple space-separated values." > "/dev/stderr"
err = 1
exit 1