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
'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

View file

@ -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();