From 6fc2d8191905d66c7307a55771f1c1aab813ec1e Mon Sep 17 00:00:00 2001 From: Paul Mansfield Date: Tue, 23 Feb 2010 23:05:03 +0000 Subject: [PATCH] Bugfix: Old versions of bash do not have =~ Versions of bash before 3.0 do not have =~ syntax to match on a regex. Changed to using a simple grep -c test instead. Fixes issues with osx and Solaris 9 and before. --- todo.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/todo.sh b/todo.sh index 9164a2a..79d79ef 100755 --- a/todo.sh +++ b/todo.sh @@ -259,13 +259,10 @@ 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)$' + action_regexp="^\(append\|app\|prepend\|prep\|replace\)$" # Check which action we are being used in as this affects what cleaning we do - if [[ $action =~ $action_regexp ]]; then + if [ `echo $action | grep -c $action_regexp` -eq 1 ]; then # These actions use sed and & as the matched string so escape it input=`echo $input | sed 's/\&/\\\&/g'` fi