about summary refs log tree commit diff
path: root/nixpkgs/pkgs/build-support/setup-hooks
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-06-18 18:30:18 +0000
committerAlyssa Ross <hi@alyssa.is>2019-06-18 18:30:18 +0000
commitef93931efff0323fd13c4270415b578c73b5ef35 (patch)
treee5b089306c481ce3237027bfb46c940fed1e2114 /nixpkgs/pkgs/build-support/setup-hooks
parentc5571a126859eb658ffd7340cb580f7d91f12bb6 (diff)
parenta1dd419c1ffacea87eba066a2bb332e03cb68f66 (diff)
downloadnixlib-ef93931efff0323fd13c4270415b578c73b5ef35.tar
nixlib-ef93931efff0323fd13c4270415b578c73b5ef35.tar.gz
nixlib-ef93931efff0323fd13c4270415b578c73b5ef35.tar.bz2
nixlib-ef93931efff0323fd13c4270415b578c73b5ef35.tar.lz
nixlib-ef93931efff0323fd13c4270415b578c73b5ef35.tar.xz
nixlib-ef93931efff0323fd13c4270415b578c73b5ef35.tar.zst
nixlib-ef93931efff0323fd13c4270415b578c73b5ef35.zip
Merge commit 'a1dd419c1ffacea87eba066a2bb332e03cb68f66'
Diffstat (limited to 'nixpkgs/pkgs/build-support/setup-hooks')
-rw-r--r--nixpkgs/pkgs/build-support/setup-hooks/patch-shebangs.sh20
1 files changed, 12 insertions, 8 deletions
diff --git a/nixpkgs/pkgs/build-support/setup-hooks/patch-shebangs.sh b/nixpkgs/pkgs/build-support/setup-hooks/patch-shebangs.sh
index f4a865e96687..3e900d0704cf 100644
--- a/nixpkgs/pkgs/build-support/setup-hooks/patch-shebangs.sh
+++ b/nixpkgs/pkgs/build-support/setup-hooks/patch-shebangs.sh
@@ -4,11 +4,14 @@
 # /usr/bin/env gets special treatment so that ".../bin/env python" is
 # rewritten to /nix/store/<hash>/bin/python.  Interpreters that are
 # already in the store are left untouched.
+# A script file must be marked as executable, otherwise it will not be
+# considered.
 
 fixupOutputHooks+=(patchShebangsAuto)
 
-# Run patch shebangs on a directory.
-# patchShebangs [--build | --host] directory
+# Run patch shebangs on a directory or file.
+# Can take multiple paths as arguments.
+# patchShebangs [--build | --host] PATH...
 
 # Flags:
 # --build : Lookup commands available at build-time
@@ -29,9 +32,7 @@ patchShebangs() {
         shift
     fi
 
-    local dir="$1"
-
-    header "patching script interpreter paths in $dir"
+    echo "patching script interpreter paths in $@"
     local f
     local oldPath
     local newPath
@@ -40,7 +41,10 @@ patchShebangs() {
     local oldInterpreterLine
     local newInterpreterLine
 
-    [ -e "$dir" ] || return 0
+    if [ $# -eq 0 ]; then
+        echo "No arguments supplied to patchShebangs" >0
+        return 0
+    fi
 
     local f
     while IFS= read -r -d $'\0' f; do
@@ -62,7 +66,7 @@ patchShebangs() {
             # - options: something starting with a '-'
             # - environment variables: foo=bar
             if $(echo "$arg0" | grep -q -- "^-.*\|.*=.*"); then
-                echo "$f: unsupported interpreter directive \"$oldInterpreterLine\" (set dontPatchShebangs=1 and handle shebang patching yourself)"
+                echo "$f: unsupported interpreter directive \"$oldInterpreterLine\" (set dontPatchShebangs=1 and handle shebang patching yourself)" >0
                 exit 1
             fi
 
@@ -95,7 +99,7 @@ patchShebangs() {
                 rm "$timestamp"
             fi
         fi
-    done < <(find "$dir" -type f -perm -0100 -print0)
+    done < <(find "$@" -type f -perm -0100 -print0)
 
     stopNest
 }