patch-shebangs: use isScript to safely check for shebang start

Fixes commonly encountered errors about broken pipes or null-bytes in
command-substitution.
This commit is contained in:
Will Dietz 2018-09-27 17:40:16 -05:00
parent f66ae2c8b2
commit 830f9fabd4

View File

@ -19,8 +19,7 @@ patchShebangs() {
local newInterpreterLine local newInterpreterLine
find "$dir" -type f -perm -0100 | while read f; do find "$dir" -type f -perm -0100 | while read f; do
if [ "$(head -1 "$f" | head -c+2)" != '#!' ]; then if ! isScript "$f"; then
# missing shebang => not a script
continue continue
fi fi