summary refs log tree commit diff
diff options
context:
space:
mode:
authorWill Dietz <github@wdtz.org>2018-09-28 13:24:37 -0500
committerGitHub <noreply@github.com>2018-09-28 13:24:37 -0500
commit14fee8442990556cc5ae59bf2f10c060b2ff113a (patch)
treeea094e48c4b4ddca23bfcf16908d6b01863e2c6c
parentf66ae2c8b20fd00853246cfd0a32fea0a7e06814 (diff)
parentf7db287960241736213c0f262ad655ce40cfc624 (diff)
downloadnixpkgs-14fee8442990556cc5ae59bf2f10c060b2ff113a.tar
nixpkgs-14fee8442990556cc5ae59bf2f10c060b2ff113a.tar.gz
nixpkgs-14fee8442990556cc5ae59bf2f10c060b2ff113a.tar.bz2
nixpkgs-14fee8442990556cc5ae59bf2f10c060b2ff113a.tar.lz
nixpkgs-14fee8442990556cc5ae59bf2f10c060b2ff113a.tar.xz
nixpkgs-14fee8442990556cc5ae59bf2f10c060b2ff113a.tar.zst
nixpkgs-14fee8442990556cc5ae59bf2f10c060b2ff113a.zip
Merge pull request #47446 from dtzWill/fix/patch-shebangs-head-error-writing-broken-pipe
patch-shebangs: use isScript to safely check for shebang start
-rw-r--r--pkgs/build-support/setup-hooks/patch-shebangs.sh12
1 files changed, 6 insertions, 6 deletions
diff --git a/pkgs/build-support/setup-hooks/patch-shebangs.sh b/pkgs/build-support/setup-hooks/patch-shebangs.sh
index d5586fccae6..d26bf735d30 100644
--- a/pkgs/build-support/setup-hooks/patch-shebangs.sh
+++ b/pkgs/build-support/setup-hooks/patch-shebangs.sh
@@ -18,11 +18,11 @@ patchShebangs() {
     local oldInterpreterLine
     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
-        fi
+    [ -e "$dir" ] || return 0
+
+    local f
+    while IFS= read -r -d $'\0' f; do
+        isScript "$f" || continue
 
         oldInterpreterLine=$(head -1 "$f" | tail -c+3)
         read -r oldPath arg0 args <<< "$oldInterpreterLine"
@@ -61,7 +61,7 @@ patchShebangs() {
                 rm "$f.timestamp"
             fi
         fi
-    done
+    done < <(find "$dir" -type f -perm -0100 -print0)
 
     stopNest
 }