diff options
author | Nikolay Amiantov <ab@fmap.me> | 2016-04-25 18:02:47 +0300 |
---|---|---|
committer | Nikolay Amiantov <ab@fmap.me> | 2016-04-25 18:02:47 +0300 |
commit | 62616ec5e211d8cfbafe31c0876a1d8cdab9e98e (patch) | |
tree | af370ae6372472fb9f640d77c9a4e423d49552b8 /pkgs/stdenv/generic | |
parent | 5e85760ff15cff9fc2cd8c8a7edb7310d276620e (diff) | |
parent | a2d38bc7fc271ca5452ec3fd057bca3f737aa9ae (diff) |
Merge commit 'refs/pull/14907/head' of git://github.com/NixOS/nixpkgs into staging
Diffstat (limited to 'pkgs/stdenv/generic')
-rw-r--r-- | pkgs/stdenv/generic/setup.sh | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 9399ff7a76437..a183aabed0e3c 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -408,6 +408,11 @@ substitute() { if [ "$p" = --subst-var ]; then varName="${params[$((n + 1))]}" + # check if the used nix attribute name is a valid bash name + if ! [[ "$varName" =~ ^[a-zA-Z_]+[a-zA-Z0-9_]*$ ]]; then + echo "substitution variables must be valid bash names, \"$varName\" isn't." + exit 1; + fi pattern="@$varName@" replacement="${!varName}" n=$((n + 1)) @@ -439,7 +444,8 @@ substituteAll() { local output="$2" # Select all environment variables that start with a lowercase character. - for envVar in $(env | sed -e $'s/^\([a-z][^=]*\)=.*/\\1/; t \n d'); do + # Will not work with nix attribute names (and thus env variables) containing '\n'. + for envVar in $(set | sed -e $'s/^\([a-z][^=]*\)=.*/\\1/; t \n d'); do if [ "$NIX_DEBUG" = "1" ]; then echo "$envVar -> ${!envVar}" fi |