Skip to content

Commit bae22ec

Browse files
authored
[SETUP] Use #!/usr/bin/env bash instead of #!/bin/bash in scripts (#11778)
Replace all #!/bin/bash shebangs with #!/usr/bin/env bash in project-owned shell scripts. Third-party dependencies and documentation code blocks are left unchanged. Some operating systems (e.g. NixOS) do not have a Bash executable at /bin/bash, so using env to locate bash improves cross-platform compatibility. For example, running dev/run-scala-test.sh on macOS may fail when Bash is installed via Homebrew at /opt/homebrew/bin/bash rather than /bin/bash, and the hardcoded #!/bin/bash shebang picks up the outdated system Bash (3.2) instead of the user-installed version. Apple ships Bash 3.2 and cannot upgrade it due to the GPLv3 license of Bash 4+, so macOS users who need modern Bash features must rely on a separately installed copy, which #!/usr/bin/env bash will correctly resolve. This aligns with the same change adopted by GitHub Actions runner (see actions/runner#314) and is also consistent with what Apache Spark does in its codebase. Additionally, a shebang check is added to .github/workflows/util/check.sh so that future PRs introducing #!/bin/bash in new or modified .sh files will be caught by the License Header Check CI workflow.
1 parent 71e0db1 commit bae22ec

File tree

77 files changed

+94
-77
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+94
-77
lines changed

.github/workflows/util/check.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,30 @@
1515
# limitations under the License.
1616

1717
export BASE_COMMIT=$1
18+
19+
RESULT=0
20+
1821
./.github/workflows/util/check.py header branch
1922
if [ $? -ne 0 ]; then
2023
./.github/workflows/util/check.py header branch --fix
2124
echo -e "\n==== Apply using:"
2225
echo "patch -p1 \<<EOF"
2326
git --no-pager diff
2427
echo "EOF"
25-
false
28+
RESULT=1
29+
fi
30+
31+
# Check that shell scripts use #!/usr/bin/env bash instead of #!/bin/bash
32+
BAD_SHEBANGS=$(git diff --relative --name-only --diff-filter='ACM' "$BASE_COMMIT" -- '*.sh' | while read -r f; do
33+
[ -f "$f" ] && head -1 "$f" | grep -q '^#!/bin/bash' && echo "$f"
34+
done)
35+
36+
if [ -n "$BAD_SHEBANGS" ]; then
37+
echo -e "\n==== The following scripts use #!/bin/bash instead of #!/usr/bin/env bash:"
38+
echo "$BAD_SHEBANGS"
39+
echo "Please replace '#!/bin/bash' with '#!/usr/bin/env bash' for portability."
40+
RESULT=1
2641
fi
2742
43+
exit $RESULT
44+

.github/workflows/util/install-flink-resources.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
# Licensed to the Apache Software Foundation (ASF) under one or more
33
# contributor license agreements. See the NOTICE file distributed with
44
# this work for additional information regarding copyright ownership.

.github/workflows/util/install-resources.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
# Licensed to the Apache Software Foundation (ASF) under one or more
33
# contributor license agreements. See the NOTICE file distributed with
44
# this work for additional information regarding copyright ownership.

dev/bloop-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
# Licensed to the Apache Software Foundation (ASF) under one or more
33
# contributor license agreements. See the NOTICE file distributed with
44
# this work for additional information regarding copyright ownership.

dev/build-arrow.sh

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

33
# Licensed to the Apache Software Foundation (ASF) under one or more
44
# contributor license agreements. See the NOTICE file distributed with

dev/build-helper-functions.sh

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

33
# Licensed to the Apache Software Foundation (ASF) under one or more
44
# contributor license agreements. See the NOTICE file distributed with

dev/build-libhdfs3.sh

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

33
# Licensed to the Apache Software Foundation (ASF) under one or more
44
# contributor license agreements. See the NOTICE file distributed with

dev/build-thirdparty.sh

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

33
# Licensed to the Apache Software Foundation (ASF) under one or more
44
# contributor license agreements. See the NOTICE file distributed with

dev/buildbundle-veloxbe.sh

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

33
# Licensed to the Apache Software Foundation (ASF) under one or more
44
# contributor license agreements. See the NOTICE file distributed with

dev/builddep-veloxbe-inc.sh

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

33
# Licensed to the Apache Software Foundation (ASF) under one or more
44
# contributor license agreements. See the NOTICE file distributed with

0 commit comments

Comments
 (0)