From bcac91d68ae19b578fcd9a5883c84996e5968186 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 26 Nov 2011 16:32:25 +0000 Subject: [PATCH] Remove quote stripping code. I'm guessing it was added due to a misunderstanding of how shell quoting works. When you invoke stow --ignore=".#.*" ... the shell strips out the quotes before the Perl process ever sees them. I can't imagine any sensible scenario in which you would need to invoke stow --ignore='"foo"' but if the user has a filename containing quotes at the beginning and end, they can now choose to ignore it (prior to this patch, they couldn't). --- bin/stow.in | 27 +++------------------------ t/stow.t | 17 +++-------------- 2 files changed, 6 insertions(+), 38 deletions(-) diff --git a/bin/stow.in b/bin/stow.in index 0db7a07..ab495a6 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -465,20 +465,19 @@ sub process_options { # clean and pre-compile any regex's at parse time 'ignore=s' => sub { - # FIXME: do we really need strip_quotes here? - my $regex = strip_quotes($_[1]); + my $regex = $_[1]; push @{$options{ignore}}, qr($regex\z); }, 'override=s' => sub { - my $regex = strip_quotes($_[1]); + my $regex = $_[1]; push @{$options{override}}, qr(\A$regex); }, 'defer=s' => sub { - my $regex = strip_quotes($_[1]); + my $regex = $_[1]; push @{$options{defer}}, qr(\A$regex); }, @@ -629,26 +628,6 @@ sub version { exit 0; } -#===== METHOD ================================================================ -# Name : strip_quotes -# Purpose : remove matching outer quotes from the given string -# Parameters: none -# Returns : n/a -# Throws : no exceptions -# Comments : none -#============================================================================= -sub strip_quotes { - my ($string) = @_; - - if ($string =~ m{\A\s*'(.*)'\s*\z}) { - return $1; - } - elsif ($string =~ m{\A\s*"(.*)"\s*\z}) { - return $1 - } - return $string; -} - # Local variables: # mode: perl diff --git a/t/stow.t b/t/stow.t index c9a021d..eddcd83 100755 --- a/t/stow.t +++ b/t/stow.t @@ -7,7 +7,7 @@ use strict; use warnings; -use Test::More tests => 10; +use Test::More tests => 9; use testutil; @@ -71,23 +71,12 @@ local @ARGV = ( ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); is_deeply($options->{override}, [qr(\Aman), qr(\Ainfo)] => 'override man and info'); -# -# Check stripping any matched quotes -# -local @ARGV = ( - "--override='man'", - '--override="info"', - 'dummy' -); -($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); -is_deeply($options->{override}, [qr(\Aman), qr(\Ainfo)] => 'strip shell quoting'); - # # Check setting ignored paths # local @ARGV = ( - '--ignore="~"', - '--ignore="\.#.*"', + '--ignore=~', + '--ignore=\.#.*', 'dummy' ); ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options();