mirror of
https://github.com/bazelbuild/bazel-skylib
synced 2024-11-27 05:43:25 +00:00
Use more portable #!/usr/bin/env bash
shebang instead of hardcoded /bin/bash. (#329)
This commit is contained in:
parent
506c17293e
commit
8e923ca4b9
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 The Bazel Authors. All rights reserved.
|
||||
#
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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}"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 The Bazel Authors. All rights reserved.
|
||||
#
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 The Bazel Authors. All rights reserved.
|
||||
#
|
||||
|
|
|
@ -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' > $@",
|
||||
)
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
echo aaa
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
echo aaa
|
||||
|
|
|
@ -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$'
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 The Bazel Authors. All rights reserved.
|
||||
#
|
||||
|
|
|
@ -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)\"",
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
#
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 The Bazel Authors. All rights reserved.
|
||||
#
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2019 The Bazel Authors. All rights reserved.
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue