diff --git a/makesure.awk b/makesure.awk index 24f754f..eae1868 100755 --- a/makesure.awk +++ b/makesure.awk @@ -41,17 +41,11 @@ BEGIN { } function makesure( i) { - while (getline > 0) { # 1st pass - defines + while (getline > 0) { Lines[NR] = $0 - if ("@define" == $1 && reparseCli()) handleDefine() - _reset() - } - Mode = "prelude" - for (i = 1; i in Lines; i++) { # 2nd pass - all the rest - $0 = Lines[NR = i] - if ($1 ~ /^@/ && "@reached_if" != $1 && "@define" != $1 && !reparseCli()) continue + if ($1 ~ /^@/ && "@reached_if" != $1 && !reparseCli()) continue if ("@options" == $1) handleOptions() - else if ("@define" == $1) { Mode = "define" } + else if ("@define" == $1) handleDefine() else if ("@shell" == $1) handleShell() else if ("@goal" == $1) { if ("@glob" == $2 || "@glob" == $3) handleGoalGlob(); else handleGoal() } else if ("@doc" == $1) handleDoc() @@ -61,14 +55,11 @@ function makesure( i) { else if ("@use_lib" == $1) handleUseLib() else if ($1 ~ /^@/) addError("Unknown directive: " $1) else handleCodeLine($0) - _reset() + for (i = 1; i < 10; i++) $i = "" # only for macos 10.15 awk version 20070501 } doWork() realExit(0) } -function _reset( j) { - for (j = 1; j < 10; j++) $j = "" # only for macos 10.15 awk version 20070501 -} function prepareArgs( i,arg) { for (i = 2; i < ARGC; i++) { diff --git a/tests/12_errors.tush b/tests/12_errors.tush index 2f6861d..3d0cc4c 100644 --- a/tests/12_errors.tush +++ b/tests/12_errors.tush @@ -1,11 +1,5 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/12_errors.sh -@ Syntax error: wrong var: '777': -@ tests/12_errors.sh:64: @define X "$777" -@ Syntax error: unterminated argument: -@ tests/12_errors.sh:65: @define X1 'unterminated -@ Syntax error: unterminated argument: -@ tests/12_errors.sh:66: @define X2 "${unterminated @ Shell code is not allowed outside goals/libs: @ tests/12_errors.sh:2: echo 'code in prelude' @ Only use @reached_if in @goal: @@ -58,6 +52,12 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/12_errors.sh @ tests/12_errors.sh:61: @goal @glob # absent glob pattern @ absent glob pattern: @ tests/12_errors.sh:62: @goal g19 @glob # absent glob pattern +@ Syntax error: wrong var: '777': +@ tests/12_errors.sh:64: @define X "$777" +@ Syntax error: unterminated argument: +@ tests/12_errors.sh:65: @define X1 'unterminated +@ Syntax error: unterminated argument: +@ tests/12_errors.sh:66: @define X2 "${unterminated @ Goal 'g1' has unknown dependency 'unknown': @ tests/12_errors.sh:18: @depends_on unknown @ Goal 'g2' uses unknown lib 'unknown': diff --git a/tests/28_revamp_define.tush b/tests/28_revamp_define.tush index b56c54e..72a63d1 100644 --- a/tests/28_revamp_define.tush +++ b/tests/28_revamp_define.tush @@ -72,12 +72,12 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/28_revamp_define_1.sh g8 $ cd "$MYDIR"; ./$MAKESURE -f tests/28_revamp_define_2_err_quoting.sh -l -@ Wrong quoting: NAME: -@ tests/28_revamp_define_2_err_quoting.sh:9: @define "NAME" 'value' @ Wrong quoting: sh: @ tests/28_revamp_define_2_err_quoting.sh:6: @shell "sh" @ Wrong quoting: tracing: @ tests/28_revamp_define_2_err_quoting.sh:7: @options "tracing" +@ Wrong quoting: NAME: +@ tests/28_revamp_define_2_err_quoting.sh:9: @define "NAME" 'value' @ Wrong quoting: g1: @ tests/28_revamp_define_2_err_quoting.sh:11: @goal "g1" @ Wrong quoting: doc: