diff options
author | volth <volth@webmaster.ms> | 2018-02-23 13:12:53 +0000 |
---|---|---|
committer | volth <volth@volth.com> | 2018-07-10 22:47:34 +0000 |
commit | 5ff872aa24983cf3e1cf28bb990042846c1a97ee (patch) | |
tree | 8aedcf3fc6edc49f9b606c8da355dc7f694c1502 /pkgs/stdenv/generic/setup.sh | |
parent | f8701caafc26f2df17ab44fd4a2511c1dc11f9bf (diff) |
substituteStream(): print warning if nothing done
Diffstat (limited to 'pkgs/stdenv/generic/setup.sh')
-rw-r--r-- | pkgs/stdenv/generic/setup.sh | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 26d28609d877..9b3ca3bf11e7 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -642,7 +642,8 @@ fi substituteStream() { local var=$1 - shift + local description=$2 + shift 2 while (( "$#" )); do case "$1" in @@ -650,6 +651,14 @@ substituteStream() { pattern="$2" replacement="$3" shift 3 + local savedvar + savedvar="${!var}" + eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}' + if [ "$pattern" != "$replacement" ]; then + if [ "${!var}" == "$savedvar" ]; then + echo "substituteStream(): WARNING: pattern '$pattern' doesn't match anything in $description" >&2 + fi + fi ;; --subst-var) @@ -662,11 +671,13 @@ substituteStream() { fi pattern="@$varName@" replacement="${!varName}" + eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}' ;; --subst-var-by) pattern="@$2@" replacement="$3" + eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}' shift 3 ;; @@ -675,8 +686,6 @@ substituteStream() { return 1 ;; esac - - eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}' done printf "%s" "${!var}" @@ -704,7 +713,7 @@ substitute() { consumeEntire content < "$input" if [ -e "$output" ]; then chmod +w "$output"; fi - substituteStream content "$@" > "$output" + substituteStream content "file '$input'" "$@" > "$output" } substituteInPlace() { @@ -726,7 +735,7 @@ substituteAllStream() { local -a args=() _allFlags - substituteStream "$1" "${args[@]}" + substituteStream "$1" "$2" "${args[@]}" } # Substitute all environment variables that start with a lowercase character and @@ -1137,7 +1146,7 @@ fixupPhase() { for hook in $setupHooks; do local content consumeEntire content < "$hook" - substituteAllStream content >> "${!outputDev}/nix-support/setup-hook" + substituteAllStream content "file '$hook'" >> "${!outputDev}/nix-support/setup-hook" unset -v content done unset -v hook |