diff --git a/makesure.awk b/makesure.awk index 4bad310..8f0f8c5 100755 --- a/makesure.awk +++ b/makesure.awk @@ -362,7 +362,7 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) { goalName = GoalNames[i] if (list && GoalsByName[goalName]) # private continue - if ((gnLen = length(goalName)) > gnMaxLen && gnLen <= 30) + if ((gnLen = length(quote2(goalName))) > gnMaxLen && gnLen <= 30) gnMaxLen = gnLen } for (i = 0; i in GoalNames; i++) { @@ -371,9 +371,9 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) { continue printf " " if (goalName in Doc) - printf "%-" gnMaxLen "s : %s\n", goalName, Doc[goalName] + printf "%-" gnMaxLen "s : %s\n", quote2(goalName), Doc[goalName] else - print goalName + print quote2(goalName) } } else { if ("timing" in Options) @@ -734,6 +734,14 @@ function reparseCli( res,i,err) { for (i=NF=0; i in res; i++) $(++NF)=res[i] } +function quote2(s,force) { + if (index(s,"'")) { + gsub(/\\/,"\\\\",s) + gsub(/'/,"\\'",s) + return "$'" s "'" + } else + return force || s ~ /[ \t\\]/ ? "'" s "'" : s +} function addLine(target, line) { target[0] = addL(target[0], line) } function addL(s, l) { return s ? s "\n" l : l } function arrPush(arr, elt) { arr[arr[-7]++] = elt } diff --git a/tests/21_parsing.tush b/tests/21_parsing.tush index 368ff94..118ed61 100644 --- a/tests/21_parsing.tush +++ b/tests/21_parsing.tush @@ -1,11 +1,11 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/21_parsing_spaces.sh -la | Available goals: -| 21_parsing 1.txt -| 21_parsing 2.txt +| '21_parsing 1.txt' +| '21_parsing 2.txt' | 21_parsing*.txt -| g1@21_parsing 1.txt -| g1@21_parsing 2.txt +| 'g1@21_parsing 1.txt' +| 'g1@21_parsing 2.txt' | g1 | test2 | test3 @@ -34,9 +34,9 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/21_parsing_comments.sh test1 $ cd "$MYDIR"; ./$MAKESURE -f tests/21_parsing_quoting.sh -l | Available goals: -| no_space : no_space -| name with spaces : name with spaces -| name with ' quote : name with ' quote +| no_space : no_space +| 'name with spaces' : name with spaces +| $'name with \' quote' : name with ' quote | default $ cd "$MYDIR"; ./$MAKESURE -f tests/21_parsing_quoting.sh