Skip to content

Commit

Permalink
Use more portable #!/usr/bin/env bash shebang instead of hardcoded …
Browse files Browse the repository at this point in the history
…/bin/bash. (#329)
  • Loading branch information
yesudeep authored Oct 25, 2021
1 parent 506c172 commit 8e923ca
Show file tree
Hide file tree
Showing 16 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docs/regenerate_docs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Copyright 2019 The Bazel Authors. All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion rules/build_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ load("//lib:new_sets.bzl", "sets")

def _empty_test_impl(ctx):
extension = ".bat" if ctx.attr.is_windows else ".sh"
content = "exit 0" if ctx.attr.is_windows else "#!/bin/bash\nexit 0"
content = "exit 0" if ctx.attr.is_windows else "#!/usr/bin/env bash\nexit 0"
executable = ctx.actions.declare_file(ctx.label.name + extension)
ctx.actions.write(
output = executable,
Expand Down
2 changes: 1 addition & 1 deletion rules/diff_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if %ERRORLEVEL% neq 0 (
test_bin = ctx.actions.declare_file(ctx.label.name + "-test.sh")
ctx.actions.write(
output = test_bin,
content = r"""#!/bin/bash
content = r"""#!/usr/bin/env bash
set -euo pipefail
F1="{file1}"
F2="{file2}"
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis_test_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Copyright 2019 The Bazel Authors. All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion tests/common_settings_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Copyright 2019 The Bazel Authors. All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion tests/copy_file/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,5 @@ copy_file(
genrule(
name = "gen",
outs = ["b.txt"],
cmd = "echo -e '#!/bin/bash\necho potato' > $@",
cmd = "echo -e '#!/usr/bin/env bash\necho potato' > $@",
)
2 changes: 1 addition & 1 deletion tests/copy_file/a.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
#!/usr/bin/env bash
echo aaa
2 changes: 1 addition & 1 deletion tests/copy_file/a_with_exec_bit.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
#!/usr/bin/env bash
echo aaa
10 changes: 5 additions & 5 deletions tests/copy_file/copy_file_tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Copyright 2019 The Bazel Authors. All rights reserved.
#
Expand Down Expand Up @@ -42,25 +42,25 @@ source "$(rlocation bazel_skylib/tests/unittest.bash)" \

function test_copy_src() {
cat "$(rlocation bazel_skylib/tests/copy_file/out/a-out.txt)" >"$TEST_log"
expect_log '^#!/bin/bash$'
expect_log '^#!/usr/bin/env bash$'
expect_log '^echo aaa$'
}

function test_copy_src_symlink() {
cat "$(rlocation bazel_skylib/tests/copy_file/out/a-out-symlink.txt)" >"$TEST_log"
expect_log '^#!/bin/bash$'
expect_log '^#!/usr/bin/env bash$'
expect_log '^echo aaa$'
}

function test_copy_gen() {
cat "$(rlocation bazel_skylib/tests/copy_file/out/gen-out.txt)" >"$TEST_log"
expect_log '^#!/bin/bash$'
expect_log '^#!/usr/bin/env bash$'
expect_log '^echo potato$'
}

function test_copy_gen_symlink() {
cat "$(rlocation bazel_skylib/tests/copy_file/out/gen-out-symlink.txt)" >"$TEST_log"
expect_log '^#!/bin/bash$'
expect_log '^#!/usr/bin/env bash$'
expect_log '^echo potato$'
}

Expand Down
2 changes: 1 addition & 1 deletion tests/diff_test/diff_test_tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Copyright 2019 The Bazel Authors. All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion tests/run_binary/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ write_file(
"@echo>>%OUT% ENV_PATH_CMD=(%ENV_PATH_CMD%)",
],
"//conditions:default": [
"#!/bin/bash",
"#!/usr/bin/env bash",
"echo > \"$OUT\" \"arg1=($1)\"",
"echo >> \"$OUT\" \"arg2=($2)\"",
"echo >> \"$OUT\" \"ENV_LOCATION=($ENV_LOCATION)\"",
Expand Down
2 changes: 1 addition & 1 deletion tests/shell_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _shell_args_test_gen_impl(ctx):
"back`echo q`uote",
]
script_content = "\n".join([
"#!/bin/bash",
"#!/usr/bin/env bash",
"myarray=" + shell.array_literal(args),
'output=$(echo "${myarray[@]}")',
# For logging:
Expand Down
4 changes: 2 additions & 2 deletions tests/unittest.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2015 The Bazel Authors. All rights reserved.
#
Expand All @@ -21,7 +21,7 @@
# A typical test suite looks like so:
#
# ------------------------------------------------------------------------
# #!/bin/bash
# #!/usr/bin/env bash
#
# source path/to/unittest.bash || exit 1
#
Expand Down
2 changes: 1 addition & 1 deletion tests/unittest_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Copyright 2019 The Bazel Authors. All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion tests/write_file/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ write_file(
name = "write_nonempty_bin",
out = "out/nonempty.sh",
content = [
"#!/bin/bash",
"#!/usr/bin/env bash",
"echo potato",
],
is_executable = True,
Expand Down
2 changes: 1 addition & 1 deletion tests/write_file/write_file_tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Copyright 2019 The Bazel Authors. All rights reserved.
#
Expand Down

0 comments on commit 8e923ca

Please sign in to comment.