As it was discussed in #13510, it is better to use #!/usr/bin/env bash instead of #!/bin/bash.
Scripts and tools: Use #!/usr/bin/env bash instead of #!/bin/bash. #14831
pull vim88 wants to merge 1 commits into bitcoin:master from vim88:proper_shebang changing 5 files +40 −2-
vim88 commented at 8:49 PM on November 28, 2018: contributor
-
practicalswift commented at 8:55 PM on November 28, 2018: contributor
Concept ACK
Take a look at how
test/lint/lint-python-shebang.shenforces the expected shebang for Python scripts. -
MarcoFalke commented at 8:55 PM on November 28, 2018: member
I thought we had a linter to lint those, but maybe the linters aren't linting themselves.
- MarcoFalke added the label Refactoring on Nov 28, 2018
- MarcoFalke added the label Scripts and tools on Nov 28, 2018
-
fanquake commented at 11:00 AM on November 29, 2018: member
utACK 50ec1c8
Checked that this is the only occurrence of
#!/bin/bashin the code.In future, please try and preface your commit message, and write a more descriptive message. i.e
scripts: Use #!/usr/bin/env bash over obsoleted #!/bin/bash. -
ch4ot1c commented at 6:02 PM on November 29, 2018: contributor
This note could be added to
developer-notes.md. -
practicalswift commented at 9:38 AM on November 30, 2018: contributor
@vim88 Could include the dev notes commit from #14846 here and keep these related changes to one PR?
Also, what about adding this:
diff --git a/test/lint/lint-python-shebang.sh b/test/lint/lint-python-shebang.sh index 4ff87f0bf..3a023fd80 100755 --- a/test/lint/lint-python-shebang.sh +++ b/test/lint/lint-python-shebang.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Shebang must use python3 (not python or python2) +# Assert expected shebang lines export LC_ALL=C EXIT_CODE=0 @@ -10,4 +10,10 @@ for PYTHON_FILE in $(git ls-files -- "*.py"); do EXIT_CODE=1 fi done +for SHELL_FILE in $(git ls-files -- "*.sh"); do + if [[ $(head -n 1 "${SHELL_FILE}") != "#!/usr/bin/env bash" && $(head -n 1 "${SHELL_FILE}") != "#!/bin/sh" ]]; then + echo "Missing expected shebang \"#!/usr/bin/env bash\" or \"#!/bin/sh\" in ${SHELL_FILE}" + EXIT_CODE=1 + fi +done exit ${EXIT_CODE}And then
git mv test/lint/lint-python-shebang.sh test/lint/lint-shebang.sh.That way we'll never have to think about this ever again :-)
-
vim88 commented at 8:13 PM on November 30, 2018: contributor
I agree that we should keep all these related changes in this PR.
-
vim88 commented at 8:26 PM on November 30, 2018: contributor
I commited here the DOC additions from #14846 about Scripts shebang to developer-notes.md.
I also added the linting part for Shell Scripts shebang. (Thanks @practicalswift!)
-
vim88 commented at 8:59 PM on November 30, 2018: contributor
It seems that the Travis CI build failed for "Lint", so the new linting part for Shell Scripts shebang works.
Missing expected shebang "#!/usr/bin/env bash" or "#!/bin/sh" in contrib/qos/tc.sh Missing expected shebang "#!/usr/bin/env bash" or "#!/bin/sh" in src/qt/res/movies/makespinner.sh ^---- failure generated from test/lint/lint-shebang.shShould I add the shebangs to those two files in this PR? Also, is
#!/usr/bin/env bashor#!/bin/shpreffered? -
practicalswift commented at 6:46 PM on December 1, 2018: contributor
@vim88 Add shebangs to
tc.shandmakespinner.shtoo. They should have#!/usr/bin/env bashsince they usebashfeatures. -
vim88 commented at 7:01 PM on December 1, 2018: contributor
I added the missing
#!/usr/bin/env bashshebang tocontrib/qos/tc.shandsrc/qt/res/movies/makespinner.sh. -
practicalswift commented at 11:15 PM on December 1, 2018: contributor
utACK 114ff903b69513fbfb7a3fc7fd19e6ef6ffa5a7e, but please squash commits
-
Scripts and tools & Docs: Used #!/usr/bin/env bash instead of obsolete #!/bin/bash, added linting for .sh files shebang and updated the Developer Notes. 688f665a5e
- vim88 force-pushed on Dec 2, 2018
-
vim88 commented at 2:23 PM on December 2, 2018: contributor
I squashed the commits.
-
practicalswift commented at 4:44 PM on December 2, 2018: contributor
utACK 688f665a5e526fda0fb797bf617412fe9cbe64fd
-
dongcarl commented at 2:33 AM on December 3, 2018: member
Fantastic! utACK 688f665
-
fanquake commented at 3:52 AM on December 3, 2018: member
re-utACK 688f665
-
Empact commented at 11:16 AM on December 4, 2018: member
utACK 688f665
- hebasto referenced this in commit 0936e2596b on Dec 6, 2018
- laanwj merged this on Dec 6, 2018
- laanwj closed this on Dec 6, 2018
-
vim88 commented at 5:20 PM on December 6, 2018: contributor
Thank you all!
- zkbot referenced this in commit 43ac2062f9 on Oct 28, 2020
- zkbot referenced this in commit 84a5830aaa on Nov 9, 2020
- Munkybooty referenced this in commit e5bc466bb3 on Aug 2, 2021
- Munkybooty referenced this in commit f0a0f3e118 on Aug 2, 2021
- Munkybooty referenced this in commit 5f65a76681 on Aug 3, 2021
- Munkybooty referenced this in commit e1d5797fb2 on Aug 5, 2021
- Munkybooty referenced this in commit 2c0d1ee1c5 on Aug 5, 2021
- Munkybooty referenced this in commit ff4892fee5 on Aug 8, 2021
- Munkybooty referenced this in commit 82e9af702a on Aug 11, 2021
- Munkybooty referenced this in commit f744ede646 on Aug 11, 2021
- Munkybooty referenced this in commit c3f109ccd0 on Aug 13, 2021
- Munkybooty referenced this in commit debac13960 on Aug 15, 2021
- MarcoFalke locked this on Sep 8, 2021