Skip to content

Commit

Permalink
Scripts and tools & Docs: Used #!/usr/bin/env bash instead of obsolet…
Browse files Browse the repository at this point in the history
…e #!/bin/bash, added linting for .sh files shebang and updated the Developer Notes.
  • Loading branch information
vim88 committed Dec 2, 2018
1 parent 60b20c8 commit 688f665
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
2 changes: 2 additions & 0 deletions contrib/qos/tc.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash
#
# Copyright (c) 2017 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
Expand Down
27 changes: 27 additions & 0 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Developer Notes
- [Strings and formatting](#strings-and-formatting)
- [Variable names](#variable-names)
- [Threads and synchronization](#threads-and-synchronization)
- [Scripts](#scripts)
- [Shebang](#shebang)
- [Source code organization](#source-code-organization)
- [GUI](#gui)
- [Subtrees](#subtrees)
Expand Down Expand Up @@ -602,6 +604,31 @@ TRY_LOCK(cs_vNodes, lockNodes);
}
```
Scripts
--------------------------
### Shebang
- Use `#!/usr/bin/env bash` instead of obsolete `#!/bin/bash`.
- [*Rationale*](https://github.com/dylanaraps/pure-bash-bible#shebang):
`#!/bin/bash` assumes it is always installed to /bin/ which can cause issues;
`#!/usr/bin/env bash` searches the user's PATH to find the bash binary.
OK:
```bash
#!/usr/bin/env bash
```

Wrong:

```bash
#!/bin/bash
```

Source code organization
--------------------------

Expand Down
2 changes: 2 additions & 0 deletions src/qt/res/movies/makespinner.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash
#
# Copyright (c) 2014-2015 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
Expand Down
2 changes: 1 addition & 1 deletion test/lint/lint-python-dead-code.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright (c) 2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,4 +10,11 @@ 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}

0 comments on commit 688f665

Please sign in to comment.