Skip to content

Commit

Permalink
Implement stricter parsing #141
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Oct 8, 2023
1 parent d55b143 commit be3f6f2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
9 changes: 9 additions & 0 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,15 @@ function reparseCli( res,i,err) {
$(++NF) = res[i]
Quotes[NF] = res[i,"quote"]
}
# validation according to https://github.com/xonixx/makesure/issues/141
for (i = 2; i <= NF; i++) {
if ("@define" == $1 && 3 == i || "@depends_on" == $1 && "@args" == $3 && i > 3)
continue
if ("\"" == Quotes[i]) {
addError("Wrong quoting: " $i)
return -1
}
}
return 0
}
function quote2(s,force) {
Expand Down
31 changes: 31 additions & 0 deletions tests/28_revamp_define.tush
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,34 @@ $ 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: 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:
@ tests/28_revamp_define_2_err_quoting.sh:12: @doc "doc"
@ Wrong quoting: goal_name:
@ tests/28_revamp_define_2_err_quoting.sh:13: @depends_on "goal_name"
@ Wrong quoting: goal_name:
@ tests/28_revamp_define_2_err_quoting.sh:14: @depends_on goal_name1 "goal_name"
@ Wrong quoting: @private:
@ tests/28_revamp_define_2_err_quoting.sh:19: @goal g2 "@private"
@ Wrong quoting: lib_name:
@ tests/28_revamp_define_2_err_quoting.sh:20: @use_lib "lib_name"
@ Wrong quoting: lib_name:
@ tests/28_revamp_define_2_err_quoting.sh:22: @lib "lib_name"
@ Wrong quoting: @glob:
@ tests/28_revamp_define_2_err_quoting.sh:24: @goal gg1 "@glob" '*.tush'
@ Wrong quoting: *.tush:
@ tests/28_revamp_define_2_err_quoting.sh:25: @goal gg2 @glob "*.tush"
@ Wrong quoting: @params:
@ tests/28_revamp_define_2_err_quoting.sh:27: @goal pg "@params" P
@ Wrong quoting: P:
@ tests/28_revamp_define_2_err_quoting.sh:29: @goal pg1 @params "P"
@ Wrong quoting: @args:
@ tests/28_revamp_define_2_err_quoting.sh:30: @depends_on pg "@args" 'value'
? 1
4 changes: 3 additions & 1 deletion tests/28_revamp_define_2_err_quoting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@goal "g1"
@doc "doc"
@depends_on "goal_name"
@depends_on goal_name "goal_name"
@depends_on goal_name1 "goal_name"

@goal goal_name
@goal goal_name1
Expand All @@ -25,7 +25,9 @@
@goal gg2 @glob "*.tush"

@goal pg "@params" P

@goal pg1 @params "P"
@depends_on pg "@args" 'value'

# GOOD:

Expand Down

0 comments on commit be3f6f2

Please sign in to comment.