From 78b01de68d6ecb65ed3b3220e96d290e116436aa Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 10 Nov 2014 13:35:09 +0100 Subject: substituteAll: Enumerate environment variables more reliably Getting the names of all environment variables is tricky. The previous implementation easily got confused by multi-line variables. The new one is more reliable but not still not perfect. This works around a segfault in Bash 4.3, where the expression "${!var}" (where var="-9") crashes under certain conditions. http://hydra.nixos.org/build/16693445 --- pkgs/stdenv/generic/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkgs/stdenv/generic/setup.sh') diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index fe801c6bb971..987d7766ce89 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -386,7 +386,7 @@ substituteAll() { local output="$2" # Select all environment variables that start with a lowercase character. - for envVar in $(env | sed "s/^[^a-z].*//" | sed "s/^\([^=]*\)=.*/\1/"); do + for envVar in $(env | sed -e $'s/^\([a-z][^=]*\)=.*/\\1/; t \n d'); do if [ "$NIX_DEBUG" = "1" ]; then echo "$envVar -> ${!envVar}" fi -- cgit 1.4.1