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
  1. vim88 commented at 8:49 PM on November 28, 2018: contributor

    As it was discussed in #13510, it is better to use #!/usr/bin/env bash instead of #!/bin/bash.

  2. practicalswift commented at 8:55 PM on November 28, 2018: contributor

    Concept ACK

    Take a look at how test/lint/lint-python-shebang.sh enforces the expected shebang for Python scripts.

  3. 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.

  4. MarcoFalke added the label Refactoring on Nov 28, 2018
  5. MarcoFalke added the label Scripts and tools on Nov 28, 2018
  6. fanquake commented at 11:00 AM on November 29, 2018: member

    utACK 50ec1c8

    Checked that this is the only occurrence of #!/bin/bash in 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.

  7. ch4ot1c commented at 6:02 PM on November 29, 2018: contributor

    This note could be added to developer-notes.md.

  8. 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 :-)

  9. vim88 commented at 8:13 PM on November 30, 2018: contributor

    I agree that we should keep all these related changes in this PR.

  10. 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!)

  11. 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.sh
    

    Should I add the shebangs to those two files in this PR? Also, is #!/usr/bin/env bash or #!/bin/sh preffered?

  12. practicalswift commented at 6:46 PM on December 1, 2018: contributor

    @vim88 Add shebangs to tc.sh and makespinner.sh too. They should have #!/usr/bin/env bash since they use bash features.

  13. vim88 commented at 7:01 PM on December 1, 2018: contributor

    I added the missing #!/usr/bin/env bash shebang to contrib/qos/tc.sh and src/qt/res/movies/makespinner.sh.

  14. practicalswift commented at 11:15 PM on December 1, 2018: contributor

    utACK 114ff903b69513fbfb7a3fc7fd19e6ef6ffa5a7e, but please squash commits

  15. 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
  16. vim88 force-pushed on Dec 2, 2018
  17. vim88 commented at 2:23 PM on December 2, 2018: contributor

    I squashed the commits.

  18. practicalswift commented at 4:44 PM on December 2, 2018: contributor

    utACK 688f665a5e526fda0fb797bf617412fe9cbe64fd

  19. dongcarl commented at 2:33 AM on December 3, 2018: member

    Fantastic! utACK 688f665

  20. fanquake commented at 3:52 AM on December 3, 2018: member

    re-utACK 688f665

  21. Empact commented at 11:16 AM on December 4, 2018: member

    utACK 688f665

  22. hebasto referenced this in commit 0936e2596b on Dec 6, 2018
  23. laanwj merged this on Dec 6, 2018
  24. laanwj closed this on Dec 6, 2018

  25. vim88 commented at 5:20 PM on December 6, 2018: contributor

    Thank you all!

  26. zkbot referenced this in commit 43ac2062f9 on Oct 28, 2020
  27. zkbot referenced this in commit 84a5830aaa on Nov 9, 2020
  28. Munkybooty referenced this in commit e5bc466bb3 on Aug 2, 2021
  29. Munkybooty referenced this in commit f0a0f3e118 on Aug 2, 2021
  30. Munkybooty referenced this in commit 5f65a76681 on Aug 3, 2021
  31. Munkybooty referenced this in commit e1d5797fb2 on Aug 5, 2021
  32. Munkybooty referenced this in commit 2c0d1ee1c5 on Aug 5, 2021
  33. Munkybooty referenced this in commit ff4892fee5 on Aug 8, 2021
  34. Munkybooty referenced this in commit 82e9af702a on Aug 11, 2021
  35. Munkybooty referenced this in commit f744ede646 on Aug 11, 2021
  36. Munkybooty referenced this in commit c3f109ccd0 on Aug 13, 2021
  37. Munkybooty referenced this in commit debac13960 on Aug 15, 2021
  38. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 18:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me