Use more portable `#!/usr/bin/env bash` shebang instead of hardcoded /bin/bash. (#329)

This commit is contained in:
Yesudeep Mangalapilly 2021-10-25 06:12:41 -07:00 committed by GitHub
parent 506c17293e
commit 8e923ca4b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 21 additions and 21 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2019 The Bazel Authors. All rights reserved.
#

View File

@ -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,

View File

@ -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}"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2019 The Bazel Authors. All rights reserved.
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2019 The Bazel Authors. All rights reserved.
#

View File

@ -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' > $@",
)

View File

@ -1,2 +1,2 @@
#!/bin/bash
#!/usr/bin/env bash
echo aaa

View File

@ -1,2 +1,2 @@
#!/bin/bash
#!/usr/bin/env bash
echo aaa

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2019 The Bazel Authors. All rights reserved.
#
@ -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$'
}

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2019 The Bazel Authors. All rights reserved.
#

View File

@ -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)\"",

View File

@ -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:

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2015 The Bazel Authors. All rights reserved.
#
@ -21,7 +21,7 @@
# A typical test suite looks like so:
#
# ------------------------------------------------------------------------
# #!/bin/bash
# #!/usr/bin/env bash
#
# source path/to/unittest.bash || exit 1
#

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2019 The Bazel Authors. All rights reserved.
#

View File

@ -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,

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2019 The Bazel Authors. All rights reserved.
#