Skip to content

Commit 4fb7c88

Browse files
committed
Capture current PATH when writing workspace env
1 parent cd4ca8f commit 4fb7c88

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

scripts/setup-workspace.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,23 @@ else
157157
fi
158158

159159
log "Writing environment to $ENV_FILE"
160+
current_path="${PATH:-}"
161+
for required in /usr/bin /bin /usr/local/bin; do
162+
case ":$current_path:" in
163+
*:"$required":*) ;;
164+
*) current_path="${current_path:+$current_path:}$required" ;;
165+
esac
166+
done
167+
if [ -n "$current_path" ]; then
168+
path_suffix=":$current_path"
169+
else
170+
path_suffix=""
171+
fi
160172
cat > "$ENV_FILE" <<ENV
161173
export JAVA_HOME="$JAVA_HOME"
162174
export JAVA17_HOME="$JAVA17_HOME"
163175
export MAVEN_HOME="$MAVEN_HOME"
164-
export PATH="\$JAVA_HOME/bin:\$MAVEN_HOME/bin:/usr/bin:/bin:/usr/local/bin\${PATH:+:\$PATH}"
176+
export PATH="\$JAVA_HOME/bin:\$MAVEN_HOME/bin$path_suffix"
165177
ENV
166178

167179
log "Workspace environment file metadata"

0 commit comments

Comments
 (0)