Skip to content

Commit

Permalink
Merge pull request #166 from xonixx/issue_165
Browse files Browse the repository at this point in the history
Issue 165
  • Loading branch information
xonixx authored Feb 24, 2024
2 parents 0577848 + b1bd29c commit 30510b1
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 8 deletions.
6 changes: 4 additions & 2 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ function handleGoalGlob( goalName,globAllGoal,globSingle,priv,i,pattern,nfMax,
} else
pattern = $(nfMax = 4)
if (NF > nfMax && "@params" != $(nfMax + 1))
addError("nothing or @params allowed after glob pattern")
addError("nothing or @params allowed after glob pattern")
else if (pattern == "")
addError("absent glob pattern")
else {
Expand Down Expand Up @@ -915,7 +915,9 @@ function reparseCli( res,i,err) {
$(++NF) = res[i]
# validation according to https://github.com/xonixx/makesure/issues/141
for (i = 2; i <= NF; i++)
if ("\"" == res[i - 1, "quote"] && !("@define" == $1 && 3 == i || "@depends_on" == $1 && "@args" == $3 && i > 3)) {
if ("\"" == res[i - 1, "quote"] && !("@define" == $1 && 3 == i ||
"@depends_on" == $1 && "@args" == $3 && i > 3 ||
"@goal" == $1 && "@glob" == $(i - 1))) {
addError("Wrong quoting: " $i)
return 0
}
Expand Down
6 changes: 4 additions & 2 deletions makesure_candidate
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function handleGoalGlob(goalName,globAllGoal,globSingle,priv,i,pattern,nfMax,gi,
}else
pattern=$(nfMax=4)
if(NF>nfMax&&"@params"!=$(nfMax+1))
addError("nothing or @params allowed after glob pattern")
addError("nothing or @params allowed after glob pattern")
else if(pattern=="")
addError("absent glob pattern")
else {
Expand Down Expand Up @@ -639,7 +639,9 @@ function reparseCli(res,i,err){
for(i=NF=0;i in res;i++)
$(++NF)=res[i]
for(i=2;i<=NF;i++)
if("\""==res[i-1,"quote"]&&!("@define"==$1&&3==i||"@depends_on"==$1&&"@args"==$3&&i>3)){
if("\""==res[i-1,"quote"]&&!("@define"==$1&&3==i||
"@depends_on"==$1&&"@args"==$3&&i>3||
"@goal"==$1&&"@glob"==$(i-1))){
addError("Wrong quoting: "$i)
return 0}
return 1}
Expand Down
2 changes: 1 addition & 1 deletion minify.awk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function minifyLine( l,subs) {
gsub(/ \/ /, "/")
gsub(/ \* /, "*")
gsub(/ \+ /, "+")
gsub(/ \|\| /, "||")
gsub(/ \|\| */, "||")
gsub(/ \| /, "|")
if (/ \? /) gsub(/ : /, ":")
gsub(/ \? /, "?")
Expand Down
2 changes: 0 additions & 2 deletions tests/28_revamp_define.tush
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ $ ./$MAKESURE -f tests/28_revamp_define_2_err_quoting.sh -l
@ 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:
Expand Down
2 changes: 1 addition & 1 deletion tests/28_revamp_define_2_err_quoting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@lib "lib_name"

@goal gg1 "@glob" '*.tush'
@goal gg2 @glob "*.tush"
@goal gg2 @glob "*.tush" # now OK (since #165)

@goal pg "@params" P

Expand Down
15 changes: 15 additions & 0 deletions tests/31_glob_interpolated.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


@goal g1 @glob "glob_test/*.txt"
echo "$ITEM"

@define G 'glob_test'

@goal g2 @glob "$G/*.txt"
echo "$ITEM"

@define G1 "$G/*.txt"

@goal g3 @glob "$G1"
echo "$ITEM"

21 changes: 21 additions & 0 deletions tests/31_glob_interpolated.tush
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

$ ./$MAKESURE -f tests/31_glob_interpolated.sh g1
| goal 'g1@glob_test/1.txt' ...
| glob_test/1.txt
| goal 'g1@glob_test/2.txt' ...
| glob_test/2.txt
| goal 'g1' [empty].

$ ./$MAKESURE -f tests/31_glob_interpolated.sh g2
| goal 'g2@glob_test/1.txt' ...
| glob_test/1.txt
| goal 'g2@glob_test/2.txt' ...
| glob_test/2.txt
| goal 'g2' [empty].

$ ./$MAKESURE -f tests/31_glob_interpolated.sh g3
| goal 'g3@glob_test/1.txt' ...
| glob_test/1.txt
| goal 'g3@glob_test/2.txt' ...
| glob_test/2.txt
| goal 'g3' [empty].

0 comments on commit 30510b1

Please sign in to comment.