diff options
-rw-r--r-- | compat/getopt.in | 23 | ||||
-rw-r--r-- | quilt.changes | 7 |
2 files changed, 22 insertions, 8 deletions
diff --git a/compat/getopt.in b/compat/getopt.in index 0bcf7b9..dfba72a 100644 --- a/compat/getopt.in +++ b/compat/getopt.in @@ -28,8 +28,8 @@ foreach my $arg (@ARGV) { # there is no reason to parse # the opts if there are no args. -if (! length(@words)) { - print ' -- '; +if (!@words) { + print " --\n"; exit; } @@ -49,22 +49,29 @@ if ($opts =~ /^\s*(?:-q\s+)?-o ([a-zA-Z:]*)?(\s+--long .*)*/) { } } -my @barewords; +my @barewords = ('--'); my @options; # set the previous option name when a param is required my $need_param; +sub quote_word +{ + my $word = shift; + $word =~ s/'/'\\''/; + return "'$word'"; +} + foreach my $word (@words) { # allow '-' to be an option value if (!$need_param && $word !~ /^-./) { - push @barewords, $word; + push @barewords, quote_word($word); next; } if ($need_param) { die "expecting param for $need_param" if $word =~ /^-./; - push @options, '"'.$word.'"'; + push @options, quote_word($word); $need_param = undef; next; } @@ -88,7 +95,7 @@ foreach my $word (@words) { while (scalar(@letters) && ($letters[$#letters] =~ /[0-9]/)) { push @digits, pop @letters; } - push @options, join('',reverse @digits); + push @options, quote_word(join('', reverse @digits)); } } } @@ -106,9 +113,9 @@ foreach my $word (@words) { $need_param = $word if $found =~ /:$/ && $param eq ''; push @options, "--$word"; - push @options, '"'."$param".'"' if $param; + push @options, quote_word($param) if $param; } } -print "@options -- @barewords" +print " @options @barewords\n" diff --git a/quilt.changes b/quilt.changes index e743129..984485f 100644 --- a/quilt.changes +++ b/quilt.changes @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Tue Mar 15 13:44:51 CET 2011 - jdelvare@suse.de + +- compat/getopt.in: Fix quoting and spacing. This way the output + matches exactly the output of getopt from util-linux, and spaces + and other special characters in filenames are properly supported. + +------------------------------------------------------------------- Sat Mar 12 15:12:38 CET 2011 - jdelvare@suse.de - quilt/grep.in: Not all implementations of find default to the |