Skip to content

Commit 1b18faf

Browse files
authored
Make eng/build.sh portable (don't hardcode /bin/bash) (#14707)
Follow-up to #14361 addressing @corngood's review feedback: `eng/build.sh` isn't portable and breaks on NixOS. - Shebang `#! /bin/bash` -> `#!/usr/bin/env bash`, matching every other script in this repo (including `build.sh` and `eng/common/*.sh`). - The hardcoded `/bin/bash` invocations of the stage 1 / stage 2 builds now use `bash` from `\`. The echoed command lines were updated to match. No behavioral change on distributions where bash lives at `/bin/bash`. Copilot-Session: fcd4cd36-f7ca-48cf-9c4d-7f9601ef3db2
1 parent 27f1450 commit 1b18faf

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

eng/build.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /bin/bash
1+
#!/usr/bin/env bash
22

33
configuration="Debug"
44
test=false
@@ -92,10 +92,10 @@ fi
9292

9393
# Log the stage 1 build command so that it's clear which arguments flow to it.
9494
if [ "$stage2" = true ]; then
95-
echo "Stage 1 build: /bin/bash \"$build_script\" ${build_args[*]}"
95+
printf 'Stage 1 build: %q %q %s\n' "$BASH" "$build_script" "$(printf '%q ' "${build_args[@]}")"
9696
fi
9797

98-
/bin/bash "$build_script" "${build_args[@]}"
98+
"$BASH" "$build_script" "${build_args[@]}"
9999
stage1_exit_code=$?
100100

101101
if [ "$stage2" != true ]; then
@@ -174,7 +174,7 @@ fi
174174
# until a stable version of MT is available in the images.
175175
stage2_build_args+=( ${stage2Arguments[@]+"${stage2Arguments[@]}"} )
176176

177-
echo "Stage 2 build: /bin/bash \"$build_script\" ${stage2_build_args[*]}"
177+
printf 'Stage 2 build: %q %q %s\n' "$BASH" "$build_script" "$(printf '%q ' "${stage2_build_args[@]}")"
178178
# Needs to run out-of-proc to not inherit the stage 1 build's state variables.
179-
/bin/bash "$build_script" "${stage2_build_args[@]}"
179+
"$BASH" "$build_script" "${stage2_build_args[@]}"
180180
exit $?

0 commit comments

Comments
 (0)