Skip to content

Commit

Permalink
Incorrect parameterized goal argument interpolation when @define goes…
Browse files Browse the repository at this point in the history
… after #152
  • Loading branch information
xonixx committed Dec 24, 2023
1 parent df3fe40 commit a1cca0a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
16 changes: 11 additions & 5 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ BEGIN {
makesure()
}

function makesure( i) {
while (getline > 0) {
function makesure( i,j) {
while (getline > 0) { # 1st pass - defines
Lines[NR] = $0
if ($1 ~ /^@/ && "@reached_if" != $1) if (reparseCli() < 0) continue
if ("@define" == $1 && reparseCli() >= 0) handleDefine()
for (j = 1; j < 10; j++) $j = "" # only for macos 10.15 awk version 20070501
}
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) if (reparseCli() < 0) continue
if ("@options" == $1) handleOptions()
else if ("@define" == $1) handleDefine()
else if ("@define" == $1) { Mode = "define" }
else if ("@shell" == $1) handleShell()
else if ("@goal" == $1) { if ("@glob" == $2 || "@glob" == $3) handleGoalGlob(); else handleGoal() }
else if ("@doc" == $1) handleDoc()
Expand All @@ -56,7 +62,7 @@ function makesure( i) {
else if ("@use_lib" == $1) handleUseLib()
else if ($1 ~ /^@/) addError("Unknown directive: " $1)
else handleCodeLine($0)
for (i = 1; i < 10; i++) $i = "" # only for macos 10.15 awk version 20070501
for (j = 1; j < 10; j++) $j = "" # only for macos 10.15 awk version 20070501
}
doWork()
realExit(0)
Expand Down
12 changes: 6 additions & 6 deletions tests/12_errors.tush
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@

$ 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:
Expand Down Expand Up @@ -52,12 +58,6 @@ $ 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':
Expand Down
4 changes: 2 additions & 2 deletions tests/28_revamp_define.tush
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a1cca0a

Please sign in to comment.