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).
This commit is contained in:
Adam Spiers 2011-11-26 16:32:25 +00:00
parent 3d414dc071
commit bcac91d68a
2 changed files with 6 additions and 38 deletions

View file

@ -465,20 +465,19 @@ sub process_options {
# clean and pre-compile any regex's at parse time # clean and pre-compile any regex's at parse time
'ignore=s' => 'ignore=s' =>
sub { sub {
# FIXME: do we really need strip_quotes here? my $regex = $_[1];
my $regex = strip_quotes($_[1]);
push @{$options{ignore}}, qr($regex\z); push @{$options{ignore}}, qr($regex\z);
}, },
'override=s' => 'override=s' =>
sub { sub {
my $regex = strip_quotes($_[1]); my $regex = $_[1];
push @{$options{override}}, qr(\A$regex); push @{$options{override}}, qr(\A$regex);
}, },
'defer=s' => 'defer=s' =>
sub { sub {
my $regex = strip_quotes($_[1]); my $regex = $_[1];
push @{$options{defer}}, qr(\A$regex); push @{$options{defer}}, qr(\A$regex);
}, },
@ -629,26 +628,6 @@ sub version {
exit 0; 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: # Local variables:
# mode: perl # mode: perl

View file

@ -7,7 +7,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 10; use Test::More tests => 9;
use testutil; use testutil;
@ -71,23 +71,12 @@ local @ARGV = (
($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options();
is_deeply($options->{override}, [qr(\Aman), qr(\Ainfo)] => 'override man and info'); 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 # Check setting ignored paths
# #
local @ARGV = ( local @ARGV = (
'--ignore="~"', '--ignore=~',
'--ignore="\.#.*"', '--ignore=\.#.*',
'dummy' 'dummy'
); );
($options, $pkgs_to_delete, $pkgs_to_stow) = process_options(); ($options, $pkgs_to_delete, $pkgs_to_stow) = process_options();