fix portability and escaping issues in match_parser pattern

This commit is contained in:
Jorge Morante 2016-05-23 07:55:10 +02:00
parent b1c5bc55e6
commit 174cd70339
1 changed files with 3 additions and 2 deletions

View File

@ -40,8 +40,9 @@ OLDIFS=$IFS
IFS=$(echo -en "\n\b") # wtf bash?
for match in $matches ; do
hint=$(get_hint $i)
linenumber=$(echo $match | sed "s/$MATCH_PARSER/\1/")
text=$(echo $match | sed "s/$MATCH_PARSER/\2/")
linenumber=$(echo $match | sed "s!${MATCH_PARSER//!\\!}!\1!")
text=$(echo $match | sed "s!${MATCH_PARSER//!\\!}!\2!")
output=$(echo -ne "$output" | sed "${linenumber}s!${text//!/\\!}!$(highlight ${text//!/\\!}) $(highlight "[${hint//!/\\!}]")!g")
match_lookup_table[$hint]=$text
i=$((i + 1))