Skip to content

Commit

Permalink
Improve parsing algorithm to handle spaces and comments #63
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Oct 14, 2021
1 parent 9a00814 commit 169afe6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ function quote2(s,force) {
gsub(/'/,"\\'",s)
return "$'" s "'"
} else
return force || s ~ /[ \t\\]/ ? "'" s "'" : s
return force || s ~ /[^a-zA-Z0-9.,@_\/=+-]/ ? "'" s "'" : s
}
function addLine(target, line) { target[0] = addL(target[0], line) }
function addL(s, l) { return s ? s "\n" l : l }
Expand Down
18 changes: 9 additions & 9 deletions tests/11_goal_glob.tush
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@

$ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh -l
| Available goals:
| 11_goal_glob*.txt : test goal_glob
| non-existent-glob*
| '11_goal_glob*.txt' : test goal_glob
| 'non-existent-glob*'
| test1
| test2
| glob_goal_name

$ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh -la
| Available goals:
| 11_goal_glob_1.txt : test goal_glob
| 11_goal_glob_2.txt : test goal_glob
| 11_goal_glob_3.txt : test goal_glob
| 11_goal_glob_10.txt : test goal_glob
| 11_goal_glob*.txt : test goal_glob
| non-existent-glob*
| 11_goal_glob_1.txt : test goal_glob
| 11_goal_glob_2.txt : test goal_glob
| 11_goal_glob_3.txt : test goal_glob
| 11_goal_glob_10.txt : test goal_glob
| '11_goal_glob*.txt' : test goal_glob
| 'non-existent-glob*'
| test1
| test2
| glob_goal_name@11_goal_glob_1.txt
Expand All @@ -29,7 +29,7 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh -d '11_goal_glob*.txt'
| 11_goal_glob_2.txt
| 11_goal_glob_3.txt
| 11_goal_glob_10.txt
| 11_goal_glob*.txt
| '11_goal_glob*.txt'

$ cd "$MYDIR"; ./$MAKESURE -f tests/11_goal_glob.sh test1
| goal '11_goal_glob_1.txt' ...
Expand Down
9 changes: 9 additions & 0 deletions tests/21_parsing.tush
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/21_parsing_quoting.sh -l
| no_space : no_space
| 'name with spaces' : name with spaces
| $'name with \' quote' : name with ' quote
| 'goal|a'
| 'goal;b'
| 'goal&c'
| default

$ cd "$MYDIR"; ./$MAKESURE -f tests/21_parsing_quoting.sh -d
| Resolved goals to reach for 'default':
| no_space
| 'name with spaces'
| $'name with \' quote'
| 'goal|a'
| 'goal;b'
| 'goal&c'
| default

$ cd "$MYDIR"; ./$MAKESURE -f tests/21_parsing_quoting.sh
Expand All @@ -55,4 +61,7 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/21_parsing_quoting.sh
| name with spaces
| goal $'name with \' quote' ...
| name with ' quote
| goal 'goal|a' [empty].
| goal 'goal;b' [empty].
| goal 'goal&c' [empty].
| goal 'default' [empty].
7 changes: 6 additions & 1 deletion tests/21_parsing_quoting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@ echo 'name with spaces' # no single quote allowed between single quotes
@doc $'name with \' quote' # $'strings' allow quote escaping
echo $'name with \' quote' # $'strings' allow quote escaping

@goal 'goal|a'
@goal 'goal;b'
@goal 'goal&c'

@goal default
@depends_on no_space 'name with spaces' $'name with \' quote'
@depends_on no_space 'name with spaces' $'name with \' quote'
@depends_on 'goal|a' 'goal;b' 'goal&c'

0 comments on commit 169afe6

Please sign in to comment.