Last active
December 19, 2018 21:56
-
-
Save kkew3/14a0cbea902e21ef85b60fd13b36c351 to your computer and use it in GitHub Desktop.
Ensure that bash shebang exists at the head of a script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/^ *$/d | |
/^#[^!]/d | |
1,/^#!\(\/bin\/\|\/usr\/bin\/env \)\(ba\)\?sh$/p | |
/^#!\(\/bin\/\|\/usr\/bin\/env \)\(ba\)\?sh$/q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# returns none-zero when there's no shebang in file "$1" | |
test -f "$1" | |
# the `awk '{print $1}' is used to be compatible with BSD wc, which prepend a TAB character | |
test "$$(sed -n -f _check_shebang_shell.sed "$1" | wc -l | awk '{print $1}')" = 1 | |
sed 'sed -n -f _check_shebang_shell.sed "$1" | tail -n1 | grep -q '^#!\(\/bin\/\|\/usr\/bin\/env \)\(ba\)\?sh$$' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment