From f4044c1ccc2361b3c127e4a9a84023a386512575 Mon Sep 17 00:00:00 2001 From: Orivej Desh Date: Thu, 31 Aug 2017 18:26:38 +0000 Subject: [PATCH] stdenv-setup: list environment variables with awk --- pkgs/stdenv/generic/setup.sh | 13 ++----------- 1 file 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