summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/stdenv/generic/setup.sh13
1 files changed, 2 insertions, 11 deletions
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh
index ff482241570c..61877701b716 100644
--- a/pkgs/stdenv/generic/setup.sh
+++ b/pkgs/stdenv/generic/setup.sh
@@ -530,15 +530,6 @@ substituteInPlace() {
     substitute "$fileName" "$fileName" "$@"
 }
 
-# List the names of the environment variables that are valid Bash names.
-listVars() {
-    # "export" prints "declare -x name=value", quoted for eval.
-    declare() {
-        echo "${2%%=*}"
-    }
-    eval "$(export)"
-    unset declare
-}
 
 # Substitute all environment variables that start with a lowercase character and
 # are valid Bash names.
@@ -547,9 +538,9 @@ substituteAll() {
     local output="$2"
     local -a args=()
 
-    for varName in $(listVars | grep '^[a-z]'); do
+    for varName in $(awk 'BEGIN { for (v in ENVIRON) if (v ~ /^[a-z][a-zA-Z0-9_]*$/) print v }'); do
         if [ "${NIX_DEBUG:-}" = "1" ]; then
-            echo "@${varName}@ -> '${!varName}'"
+            printf "@%s@ -> %q\n" "${varName}" "${!varName}"
         fi
         args+=("--subst-var" "$varName")
     done