From 830f9fabd4a564bfbc3fbfc33a62b02010c0a7a5 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Thu, 27 Sep 2018 17:40:16 -0500 Subject: [PATCH] patch-shebangs: use isScript to safely check for shebang start Fixes commonly encountered errors about broken pipes or null-bytes in command-substitution. --- pkgs/build-support/setup-hooks/patch-shebangs.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/setup-hooks/patch-shebangs.sh b/pkgs/build-support/setup-hooks/patch-shebangs.sh index d5586fccae6..0ac81102658 100644 --- a/pkgs/build-support/setup-hooks/patch-shebangs.sh +++ b/pkgs/build-support/setup-hooks/patch-shebangs.sh @@ -19,9 +19,8 @@ patchShebangs() { local newInterpreterLine find "$dir" -type f -perm -0100 | while read f; do - if [ "$(head -1 "$f" | head -c+2)" != '#!' ]; then - # missing shebang => not a script - continue + if ! isScript "$f"; then + continue fi oldInterpreterLine=$(head -1 "$f" | tail -c+3)