From 487574c865c0b150d83bc37bfda44c0051f91973 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Mon, 16 Nov 2020 14:15:52 +0100 Subject: [PATCH] [type/__dma] Convert AWK to loop over same file twice --- type/__dma/files/update_dma_conf.awk | 8 ++++++++ type/__dma/gencode-remote | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/type/__dma/files/update_dma_conf.awk b/type/__dma/files/update_dma_conf.awk index 2f60a3d..15ef7bf 100644 --- a/type/__dma/files/update_dma_conf.awk +++ b/type/__dma/files/update_dma_conf.awk @@ -88,6 +88,12 @@ BEGIN { FS = "\n" EQS = "[ \t]" # copied from dma/conf.c + if (ARGV[2]) exit (e=1) + + # Loop over file twice! + ARGV[2] = ARGV[1] + ARGC++ + # read the "should" state into the `conf` array. while (getline < "/dev/stdin") { word = first($0, EQS) @@ -165,6 +171,8 @@ NR > FNR { } END { + if (e) exit + # print rest of config options ( for (word in conf) print_confs(word) } diff --git a/type/__dma/gencode-remote b/type/__dma/gencode-remote index a33388d..fa676d4 100755 --- a/type/__dma/gencode-remote +++ b/type/__dma/gencode-remote @@ -141,7 +141,7 @@ then # at the end of the file. cat <<-CODE - awk $(drop_awk_comments "${__type:?}/files/update_dma_conf.awk") $(quote "${dma_conf}") $(quote "${dma_conf}") <<'EOF' >$(quote "${dma_conf}.tmp") \ + awk $(drop_awk_comments "${__type:?}/files/update_dma_conf.awk") $(quote "${dma_conf}") <<'EOF' >$(quote "${dma_conf}.tmp") \ && cat $(quote "${dma_conf}.tmp") >$(quote "${dma_conf}") ${conf_should} EOF