if ! "$AWK" -v prefix="$CONFIG_PREFIX" \
-v warnoverride="$WARNOVERRIDE" \
-v strict="$STRICT" \
+ -v outfile="$TMP_FILE.new" \
-v builtin="$BUILTIN" \
-v warnredun="$WARNREDUN" '
BEGIN {
# Not a config or not in merge file - keep it
if (cfg == "" || !(cfg in merge_cfg)) {
- print $0 >> ARGV[3]
+ print $0 >> outfile
next
}
# BUILTIN: do not demote y to m
if (builtin == "true" && new_val ~ /=m$/ && prev_val ~ /=y$/) {
warn_builtin(cfg, prev_val, new_val)
- print $0 >> ARGV[3]
+ print $0 >> outfile
skip_merge[merge_cfg_line[cfg]] = 1
next
}
# "=n" is the same as "is not set"
if (prev_val ~ /=n$/ && new_val ~ / is not set$/) {
- print $0 >> ARGV[3]
+ print $0 >> outfile
next
}
}
}
- # output file, skip all lines
- FILENAME == ARGV[3] {
- nextfile
- }
-
END {
# Newline in case base file lacks trailing newline
- print "" >> ARGV[3]
+ print "" >> outfile
# Append merge file, skipping lines marked for builtin preservation
for (i = 1; i <= merge_total; i++) {
if (!(i in skip_merge)) {
- print merge_lines[i] >> ARGV[3]
+ print merge_lines[i] >> outfile
}
}
if (strict_violated) {
exit 1
}
}' \
- "$ORIG_MERGE_FILE" "$TMP_FILE" "$TMP_FILE.new"; then
+ "$ORIG_MERGE_FILE" "$TMP_FILE"; then
# awk exited non-zero, strict mode was violated
STRICT_MODE_VIOLATED=true
fi