Skip to content

Commit

Permalink
goenv-init: Fix use of optional variables that should not crash the c…
Browse files Browse the repository at this point in the history
…alling shell if unset

Just use the ${variable:-} syntax to accept unset variables
  • Loading branch information
Salamandar committed Dec 26, 2024
1 parent 8ea5cab commit faaad76
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libexec/goenv-init
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ EOL
cat <<EOL
export GOENV_SHELL=${shell}
export GOENV_ROOT=${GOENV_ROOT}
if [ -z "\${GOENV_RC_FILE}" ]; then
if [ -z "\${GOENV_RC_FILE:-}" ]; then
GOENV_RC_FILE="\${HOME}/.goenvrc"
fi
if [ -e "\${GOENV_RC_FILE}" ]; then
if [ -e "\${GOENV_RC_FILE:-}" ]; then
source "\${GOENV_RC_FILE}"
fi
if [ "\${PATH#*\$GOENV_ROOT/shims}" = "\${PATH}" ]; then
if [ "\${GOENV_PATH_ORDER}" = "front" ] ; then
if [ "\${GOENV_PATH_ORDER:-}" = "front" ] ; then
export PATH="\${GOENV_ROOT}/shims:\${PATH}"
else
export PATH="\${PATH}:\${GOENV_ROOT}/shims"
Expand Down

0 comments on commit faaad76

Please sign in to comment.