Merge pull request #35304 from volth/patch-97
[staging] substitute() print warning if does nothing
This commit is contained in:
commit
f19bb8321a
1 changed files with 15 additions and 6 deletions
|
@ -645,7 +645,8 @@ fi
|
|||
|
||||
substituteStream() {
|
||||
local var=$1
|
||||
shift
|
||||
local description=$2
|
||||
shift 2
|
||||
|
||||
while (( "$#" )); do
|
||||
case "$1" in
|
||||
|
@ -653,6 +654,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)
|
||||
|
@ -669,11 +678,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
|
||||
;;
|
||||
|
||||
|
@ -682,8 +693,6 @@ substituteStream() {
|
|||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}'
|
||||
done
|
||||
|
||||
printf "%s" "${!var}"
|
||||
|
@ -711,7 +720,7 @@ substitute() {
|
|||
consumeEntire content < "$input"
|
||||
|
||||
if [ -e "$output" ]; then chmod +w "$output"; fi
|
||||
substituteStream content "$@" > "$output"
|
||||
substituteStream content "file '$input'" "$@" > "$output"
|
||||
}
|
||||
|
||||
substituteInPlace() {
|
||||
|
@ -733,7 +742,7 @@ substituteAllStream() {
|
|||
local -a args=()
|
||||
_allFlags
|
||||
|
||||
substituteStream "$1" "${args[@]}"
|
||||
substituteStream "$1" "$2" "${args[@]}"
|
||||
}
|
||||
|
||||
# Substitute all environment variables that start with a lowercase character and
|
||||
|
@ -1144,7 +1153,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
|
||||
|
|
Loading…
Reference in a new issue