From 169afe6afe3ed8436f2b731949307b6537dc4fa1 Mon Sep 17 00:00:00 2001 From: xonix Date: Thu, 14 Oct 2021 15:29:38 +0300 Subject: [PATCH] Improve parsing algorithm to handle spaces and comments #63 --- makesure.awk | 2 +- tests/11_goal_glob.tush | 18 +++++++++--------- tests/21_parsing.tush | 9 +++++++++ tests/21_parsing_quoting.sh | 7 ++++++- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/makesure.awk b/makesure.awk index 26e3ca3..f012ceb 100755 --- a/makesure.awk +++ b/makesure.awk @@ -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 } diff --git a/tests/11_goal_glob.tush b/tests/11_goal_glob.tush index eb549ee..59ceecc 100644 --- a/tests/11_goal_glob.tush +++ b/tests/11_goal_glob.tush @@ -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 @@ -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' ... diff --git a/tests/21_parsing.tush b/tests/21_parsing.tush index 397fd38..06acff3 100644 --- a/tests/21_parsing.tush +++ b/tests/21_parsing.tush @@ -39,6 +39,9 @@ $ 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 @@ -46,6 +49,9 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/21_parsing_quoting.sh -d | no_space | 'name with spaces' | $'name with \' quote' +| 'goal|a' +| 'goal;b' +| 'goal&c' | default $ cd "$MYDIR"; ./$MAKESURE -f tests/21_parsing_quoting.sh @@ -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]. diff --git a/tests/21_parsing_quoting.sh b/tests/21_parsing_quoting.sh index 6c44a3e..6e095d1 100644 --- a/tests/21_parsing_quoting.sh +++ b/tests/21_parsing_quoting.sh @@ -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' \ No newline at end of file +@depends_on no_space 'name with spaces' $'name with \' quote' +@depends_on 'goal|a' 'goal;b' 'goal&c' \ No newline at end of file