From e79b1629f5aaf14de7ce5467732a446ca9c23cd6 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Tue, 31 May 2011 15:28:46 +0200 Subject: [PATCH] Perform cleaninput() escaping without sed. No need for invoking sed; Bash's global pattern substitution can be used. --- todo.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/todo.sh b/todo.sh index 909a495..9920e60 100755 --- a/todo.sh +++ b/todo.sh @@ -274,8 +274,10 @@ cleaninput() if [ "$1" = "for sed" ]; then # This action uses sed with "|" as the substitution separator, and & as # the matched string; these must be escaped. - # Backslashes must be escaped, too. - input=`echo $input | sed -e 's+\\\+\\\\\\\\+g' -e 's/\&/\\\&/g' -e 's/|/\\\\|/g'` + # Backslashes must be escaped, too, and before the other stuff. + input=${input//\\/\\\\} + input=${input//|/\\|} + input=${input//&/\\&} fi }