mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 14:54:29 +01:00
makeWrapper: accept --argv0
flag (/cc #9562)
By default `makeWrapper` will not set argv[0] (this is a reversion to the old default behavior). Based on the breakage we have seen from changing the default, this is what most people want. The `wrapProgram` function will send `--argv0 '"$0"'` to `makeWrapper`, i.e. it will continue to pass-through the argv[0] that the wrapper is called with.
This commit is contained in:
parent
1464a4de57
commit
61cad61ebf
1 changed files with 9 additions and 3 deletions
|
@ -2,7 +2,7 @@ makeWrapper() {
|
||||||
local original=$1
|
local original=$1
|
||||||
local wrapper=$2
|
local wrapper=$2
|
||||||
local params varName value command separator n fileNames
|
local params varName value command separator n fileNames
|
||||||
local flagsBefore flags
|
local argv0 flagsBefore flags
|
||||||
|
|
||||||
mkdir -p "$(dirname $wrapper)"
|
mkdir -p "$(dirname $wrapper)"
|
||||||
|
|
||||||
|
@ -68,11 +68,17 @@ makeWrapper() {
|
||||||
n=$((n + 1))
|
n=$((n + 1))
|
||||||
flagsBefore="$flagsBefore $flags"
|
flagsBefore="$flagsBefore $flags"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "$p" = "--argv0"; then
|
||||||
|
argv0=${params[$((n + 1))]}
|
||||||
|
n=$((n + 1))
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Note: extraFlagsArray is an array containing additional flags
|
# Note: extraFlagsArray is an array containing additional flags
|
||||||
# that may be set by --run actions.
|
# that may be set by --run actions.
|
||||||
echo exec -a '"$0"' "$original" $flagsBefore '"${extraFlagsArray[@]}"' '"$@"' >> $wrapper
|
echo exec ${argv0:+-a $argv0} "$original" \
|
||||||
|
$flagsBefore '"${extraFlagsArray[@]}"' '"$@"' >> $wrapper
|
||||||
|
|
||||||
chmod +x $wrapper
|
chmod +x $wrapper
|
||||||
}
|
}
|
||||||
|
@ -98,5 +104,5 @@ wrapProgram() {
|
||||||
local prog="$1"
|
local prog="$1"
|
||||||
local hidden="$(dirname "$prog")/.$(basename "$prog")"-wrapped
|
local hidden="$(dirname "$prog")/.$(basename "$prog")"-wrapped
|
||||||
mv $prog $hidden
|
mv $prog $hidden
|
||||||
makeWrapper $hidden $prog "$@"
|
makeWrapper $hidden $prog --argv0 '"$0"' "$@"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue