Skip to content

Commit

Permalink
Fix some of the perl shell REs
Browse files Browse the repository at this point in the history
  • Loading branch information
holdenk committed Sep 15, 2013
1 parent 4727370 commit 928fde8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions backend/Unicorn/Shell.pm
Expand Up @@ -15,12 +15,12 @@ sub fix_shell {
#Probably!
#Handle with [-e foo -e bar]
# http://www.pixelbeat.org/programming/shell_script_mistakes.html
$rt =~ s/^\s*if\s*\[\s*\-e\s*(\w+?)\s*\-e\s*(\w+?)\s*\]\s*$/if [-e $1] || [-e $2]/;
$rt =~ s/^\s*if\s*\[\s*\-e\s*(\w+?)\s*\-e\s*(\w+?)\s*\]\s*/if [-e $1] || [-e $2]/;
#Double negative
$rt =~ s/^\s*if\s*\[\s*\!\-z\s*(\"\$\w*\")\]\s*$/if [$1]/;
$rt =~ s/^\s*if\s+\[\s*\!\-z\s*(\"\$\w+\")\]\s*/if [$1]/;
#Check for cat pipe to grep
#i.e cat foo | grep baz
$rt =~ s/^\s*cat\s*(\w+)\s*\|\s*grep\s+([\w\"\\]+)\s*$/grep $2 < $1/
$rt =~ s/^\s*cat\s*(\w+)\s*\|\s*grep\s+([\w\"\\]+)\s*/grep $2 < $1/
} else {
return 0;
}
Expand All @@ -38,7 +38,7 @@ sub check_shell {
return 1;
}
#Double negative
if ($rt =~ /\[\s*\!\-z\"\$\w*\"\]/) {
if ($rt =~ /\[\s*\!\-z\"\$\w+\"\]/) {
return 1;
}
#Check for cat pipe to grep
Expand Down

0 comments on commit 928fde8

Please sign in to comment.