Skip to content

Commit 5f47be1

Browse files
dagomez137nathanchance
authored andcommitted
scripts: kconfig: merge_config.sh: pass output file as awk variable
The refactoring commit 5fa9b82 ("scripts: kconfig: merge_config.sh: refactor from shell/sed/grep to awk") passes $TMP_FILE.new as ARGV[3] to awk, using it as both an output destination and an input file argument. When the base file is empty, nothing is written to ARGV[3] during processing, so awk fails trying to open it for reading: awk: cmd. line:52: fatal: cannot open file `./.tmp.config.grcQin34jb.new' for reading: No such file or directory mv: cannot stat './.tmp.config.grcQin34jb.new': No such file or directory Pass the output path via -v outfile instead and drop the FILENAME == ARGV[3] { nextfile }. Fixes: 5fa9b82 ("scripts: kconfig: merge_config.sh: refactor from shell/sed/grep to awk") Signed-off-by: Daniel Gomez <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Nathan Chancellor <[email protected]>
1 parent 3b4a3a0 commit 5f47be1

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

scripts/kconfig/merge_config.sh

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
151151
if ! "$AWK" -v prefix="$CONFIG_PREFIX" \
152152
-v warnoverride="$WARNOVERRIDE" \
153153
-v strict="$STRICT" \
154+
-v outfile="$TMP_FILE.new" \
154155
-v builtin="$BUILTIN" \
155156
-v warnredun="$WARNREDUN" '
156157
BEGIN {
@@ -212,7 +213,7 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
212213
213214
# Not a config or not in merge file - keep it
214215
if (cfg == "" || !(cfg in merge_cfg)) {
215-
print $0 >> ARGV[3]
216+
print $0 >> outfile
216217
next
217218
}
218219
@@ -222,7 +223,7 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
222223
# BUILTIN: do not demote y to m
223224
if (builtin == "true" && new_val ~ /=m$/ && prev_val ~ /=y$/) {
224225
warn_builtin(cfg, prev_val, new_val)
225-
print $0 >> ARGV[3]
226+
print $0 >> outfile
226227
skip_merge[merge_cfg_line[cfg]] = 1
227228
next
228229
}
@@ -235,7 +236,7 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
235236
236237
# "=n" is the same as "is not set"
237238
if (prev_val ~ /=n$/ && new_val ~ / is not set$/) {
238-
print $0 >> ARGV[3]
239+
print $0 >> outfile
239240
next
240241
}
241242
@@ -246,25 +247,20 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
246247
}
247248
}
248249
249-
# output file, skip all lines
250-
FILENAME == ARGV[3] {
251-
nextfile
252-
}
253-
254250
END {
255251
# Newline in case base file lacks trailing newline
256-
print "" >> ARGV[3]
252+
print "" >> outfile
257253
# Append merge file, skipping lines marked for builtin preservation
258254
for (i = 1; i <= merge_total; i++) {
259255
if (!(i in skip_merge)) {
260-
print merge_lines[i] >> ARGV[3]
256+
print merge_lines[i] >> outfile
261257
}
262258
}
263259
if (strict_violated) {
264260
exit 1
265261
}
266262
}' \
267-
"$ORIG_MERGE_FILE" "$TMP_FILE" "$TMP_FILE.new"; then
263+
"$ORIG_MERGE_FILE" "$TMP_FILE"; then
268264
# awk exited non-zero, strict mode was violated
269265
STRICT_MODE_VIOLATED=true
270266
fi

0 commit comments

Comments
 (0)