From 197a43764edf08e29747b57f808514e56c4ddf0c Mon Sep 17 00:00:00 2001 From: xonix Date: Tue, 19 Sep 2023 01:30:15 +0300 Subject: [PATCH] Revamp `@define` #140 : fix for busybox awk --- dbg.awk | 1 + makesure.awk | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dbg.awk b/dbg.awk index a274327..e00e7d8 100644 --- a/dbg.awk +++ b/dbg.awk @@ -1,5 +1,6 @@ function dbgA(name, arr, i,v) { print "--- " name ": "; for (i in arr) { v = arr[i];gsub(SUBSEP,",",i);printf "%6s : %s\n", i, v }} function dbgAO(name, arr, i) { print "--- " name ": "; for (i = 0; i in arr; i++) printf "%2s : %s\n", i, arr[i] } +function dbgLine( i) { print "--- NR=" NR; for (i=1; i<=NF; i++) printf "%2s : %s\n", i, $i } function indent(ind) { printf "%" ind * 2 "s", "" } diff --git a/makesure.awk b/makesure.awk index 42d26dc..2f71699 100755 --- a/makesure.awk +++ b/makesure.awk @@ -863,7 +863,7 @@ function parseCli_2(line, vars, res, pos,c,c1,isDoll,q,var,inDef,defVal,val,w, # print "var="var if (var !~ /^[_A-Za-z][_A-Za-z0-9]*$/) return "wrong var: '" var "'" - w = w ((val = vars[var]) != "" ? val : defVal) + w = (w) ((val = vars[var]) != "" ? val : defVal) continue } w = w c @@ -891,13 +891,13 @@ function reparseCli( res,i,err) { if (err) { addError("Syntax error: " err) return -1 - } else { - $0 = "" # only for macos 10.15 awk version 20070501 - for (i = NF = 0; i in res; i++) { - $(++NF) = res[i] - Quotes[NF] = res[i,"quote"] - } } + $0 = "" # only for macos 10.15 awk version 20070501 + for (i = NF = 0; i in res; i++) { + $(++NF) = res[i] + Quotes[NF] = res[i,"quote"] + } + return 0 } function quote2(s,force) { if (index(s,"'")) {