Skip to content

Commit

Permalink
Correctly fixed regexp quoting issue for bash v3.1.x and v3.2.x.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Cordasco committed Jan 7, 2010
1 parent 4c76f04 commit 394c4c7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion todo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,13 @@ cleaninput()
# Replace newlines with spaces Always
input=`echo $input | tr -d '\r|\n'`

# Storing regexp in variable fixes quoting difference between
# bash v3.1.x and v3.2.x see:
# http://stackoverflow.com/questions/218156/bash-regex-with-quotes
action_regexp='^(append|app|prepend|prep|replace)$'

# Check which action we are being used in as this affects what cleaning we do
if [[ $action =~ '^(append|app|prepend|prep|replace)$' ]]; then
if [[ $action =~ $action_regexp ]]; then
# These actions use sed and & as the matched string so escape it
input=`echo $input | sed 's/\&/\\\&/g'`
fi
Expand Down

0 comments on commit 394c4c7

Please sign in to comment.