mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2025-01-01 00:12:39 +03:00
Merge pull request #60559 from JohnAZoidberg/patchshebangs-multiple-args
patchShebangs: Allow multiple args
This commit is contained in:
commit
87a69edf67
@ -4,11 +4,14 @@
|
|||||||
# /usr/bin/env gets special treatment so that ".../bin/env python" is
|
# /usr/bin/env gets special treatment so that ".../bin/env python" is
|
||||||
# rewritten to /nix/store/<hash>/bin/python. Interpreters that are
|
# rewritten to /nix/store/<hash>/bin/python. Interpreters that are
|
||||||
# already in the store are left untouched.
|
# already in the store are left untouched.
|
||||||
|
# A script file must be marked as executable, otherwise it will not be
|
||||||
|
# considered.
|
||||||
|
|
||||||
fixupOutputHooks+=(patchShebangsAuto)
|
fixupOutputHooks+=(patchShebangsAuto)
|
||||||
|
|
||||||
# Run patch shebangs on a directory.
|
# Run patch shebangs on a directory or file.
|
||||||
# patchShebangs [--build | --host] directory
|
# Can take multiple paths as arguments.
|
||||||
|
# patchShebangs [--build | --host] PATH...
|
||||||
|
|
||||||
# Flags:
|
# Flags:
|
||||||
# --build : Lookup commands available at build-time
|
# --build : Lookup commands available at build-time
|
||||||
@ -29,9 +32,7 @@ patchShebangs() {
|
|||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local dir="$1"
|
echo "patching script interpreter paths in $@"
|
||||||
|
|
||||||
header "patching script interpreter paths in $dir"
|
|
||||||
local f
|
local f
|
||||||
local oldPath
|
local oldPath
|
||||||
local newPath
|
local newPath
|
||||||
@ -40,7 +41,10 @@ patchShebangs() {
|
|||||||
local oldInterpreterLine
|
local oldInterpreterLine
|
||||||
local newInterpreterLine
|
local newInterpreterLine
|
||||||
|
|
||||||
[ -e "$dir" ] || return 0
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "No arguments supplied to patchShebangs" >0
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
local f
|
local f
|
||||||
while IFS= read -r -d $'\0' f; do
|
while IFS= read -r -d $'\0' f; do
|
||||||
@ -62,7 +66,7 @@ patchShebangs() {
|
|||||||
# - options: something starting with a '-'
|
# - options: something starting with a '-'
|
||||||
# - environment variables: foo=bar
|
# - environment variables: foo=bar
|
||||||
if $(echo "$arg0" | grep -q -- "^-.*\|.*=.*"); then
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -95,7 +99,7 @@ patchShebangs() {
|
|||||||
rm "$timestamp"
|
rm "$timestamp"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done < <(find "$dir" -type f -perm -0100 -print0)
|
done < <(find "$@" -type f -perm -0100 -print0)
|
||||||
|
|
||||||
stopNest
|
stopNest
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user