1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-22 13:41:26 +00:00

stdenv substituteAll: use yet another implementation

It turned out that process substitution fed into a while-cycle
isn't recognized during darwin bootstrap:
http://hydra.nixos.org/build/35382446/nixlog/1/raw

Also fix broken NIX_DEBUG output, noticed by abbradar.
This commit is contained in:
Vladimír Čunát 2016-05-08 19:37:37 +02:00
parent e892c52737
commit 62fc8859c1

View file

@ -398,7 +398,7 @@ substitute() {
content="${content%X}"
for ((n = 2; n < ${#params[*]}; n += 1)); do
p=${params[$n]}
p="${params[$n]}"
if [ "$p" = --replace ]; then
pattern="${params[$((n + 1))]}"
@ -448,13 +448,18 @@ substituteAll() {
local -a args=()
# We need to be careful due to vars with multi-line contents or weird names.
while IFS= read -r -d '' varName; do
local IFS==
local varNames="$(env -0 | cut -z -d= -f1 | grep -z -v '^[_A-Z]' | tr '\000' '=')"
local varName
for varName in $varNames; do
if [ "$NIX_DEBUG" = "1" ]; then
echo "@varName@ -> '${varName}'"
echo "@${varName}@ -> '${!varName}'"
fi
args+=("--subst-var" "$varName")
done < <(env -0 | cut -z -d= -f1 | grep -z -v '^[_A-Z]')
done
# restore default $IFS for the child
IFS=$' \t\n'
substitute "$input" "$output" "${args[@]}"
}