Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion nvs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

# Enable the nvsudo() shell function to modify the PATH of the sudo environment.
if [ -n "${NVS_CURRENT}" ]; then
export PATH="${NVS_CURRENT}:$PATH"
if [[ ! "$PATH" == *"${NVS_CURRENT}:"* ]]; then
export PATH="${NVS_CURRENT}:$PATH"
fi
fi

export NVS_EXECUTE=1
Expand Down
8 changes: 6 additions & 2 deletions nvs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,14 @@ fi
# If some version is linked as the default, begin by using that version.
if [ -d "${NVS_HOME}/default" ]; then
if [ -f "${NVS_HOME}/default/bin/node" ]; then
export PATH="${NVS_HOME}/default/bin:${PATH}"
if [[ ! "$PATH" == *"${NVS_HOME}/default/bin"* ]]; then
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I don't think this syntax is compatible with all POSIX shells. This script file is not always executed via bash; it needs to be sourced directly from the user's preferred shell.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for POSIX compatibility you need to use case.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shebang desides the work of functionality, shellcheck will answer.

export PATH="${NVS_HOME}/default/bin:${PATH}"
fi
unset NPM_CONFIG_PREFIX
elif [ -f "${NVS_HOME}/default/node" ]; then
export PATH="${NVS_HOME}/default:${PATH}"
if [[ ! "$PATH" == *"${NVS_HOME}/default/bin"* ]]; then
export PATH="${NVS_HOME}/default:${PATH}"
fi
unset NPM_CONFIG_PREFIX
fi
fi
Expand Down