about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorRick van Schijndel <Mindavi@users.noreply.github.com>2024-02-16 18:33:27 +0100
committerGitHub <noreply@github.com>2024-02-16 18:33:27 +0100
commitb728d76d0e52eb7647c51ff9b23c94c353163091 (patch)
tree3bac8a55fb1c0c5ce2976b9e394540e32242ec79 /pkgs/build-support
parent98c3051984d6f86ec28186fb9e194f9986858c1b (diff)
parentc47f2452530b9cdb58de578f1c44c37e8aa616f0 (diff)
Merge pull request #255463 from emilylange/stdenv/patch-shebangs-trailing-newline
patch-shebangs: fix crash with shebang without trailing newline
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/setup-hooks/patch-shebangs.sh5
1 files changed, 4 insertions, 1 deletions
diff --git a/pkgs/build-support/setup-hooks/patch-shebangs.sh b/pkgs/build-support/setup-hooks/patch-shebangs.sh
index a22f989362c4a..80a29d727c858 100644
--- a/pkgs/build-support/setup-hooks/patch-shebangs.sh
+++ b/pkgs/build-support/setup-hooks/patch-shebangs.sh
@@ -72,7 +72,10 @@ patchShebangs() {
     while IFS= read -r -d $'\0' f; do
         isScript "$f" || continue
 
-        read -r oldInterpreterLine < "$f"
+        # read exits unclean if the shebang does not end with a newline, but still assigns the variable.
+        # So if read returns errno != 0, we check if the assigned variable is non-empty and continue.
+        read -r oldInterpreterLine < "$f" || [ "$oldInterpreterLine" ]
+
         read -r oldPath arg0 args <<< "${oldInterpreterLine:2}"
 
         if [[ -z "${pathName:-}" ]]; then