diff options
Diffstat (limited to 'nixpkgs/pkgs/stdenv/generic/setup.sh')
-rw-r--r-- | nixpkgs/pkgs/stdenv/generic/setup.sh | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/nixpkgs/pkgs/stdenv/generic/setup.sh b/nixpkgs/pkgs/stdenv/generic/setup.sh index ec8df76f2c79..efb233312b57 100644 --- a/nixpkgs/pkgs/stdenv/generic/setup.sh +++ b/nixpkgs/pkgs/stdenv/generic/setup.sh @@ -815,6 +815,8 @@ fi ###################################################################### # Textual substitution functions. +# only log once, due to max logging limit on hydra +_substituteStream_has_warned_replace_deprecation="" substituteStream() { local var=$1 @@ -822,8 +824,24 @@ substituteStream() { shift 2 while (( "$#" )); do + local is_required=1 + local is_quiet="" case "$1" in + --replace-quiet) + is_quiet=1 + ;& --replace) + # deprecated 2023-11-22 + # this will either get removed, or switch to the behaviour of --replace-fail in the future + if [ -z "$_substituteStream_has_warned_replace_deprecation" ]; then + echo "substituteStream(): WARNING: '--replace' is deprecated, use --replace-{fail,warn,quiet}. ($description)" >&2 + _substituteStream_has_warned_replace_deprecation=1 + fi + ;& + --replace-warn) + is_required="" + ;& + --replace-fail) pattern="$2" replacement="$3" shift 3 @@ -832,7 +850,14 @@ substituteStream() { 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 + if [ -z "$is_required" ]; then + if [ -z "$is_quiet" ]; then + printf "substituteStream(): WARNING: pattern %q doesn't match anything in %s\n" "$pattern" "$description" >&2 + fi + else + printf "substituteStream(): ERROR: pattern %q doesn't match anything in %s\n" "$pattern" "$description" >&2 + return 1 + fi fi fi ;; |