diff --git a/G/G b/G/G index 9d0562d..f47e984 100755 --- a/G/G +++ b/G/G @@ -34,9 +34,11 @@ necessarily on the same line. If a parent dir contains a B<.git> dir B is used. -=item B<--i> +=item B<-->I -Ignore case for all following options. +Apply single letter option X to all following options. + +E.g. B<--i> will prepend B<-i> to all following options. =item I @@ -60,7 +62,7 @@ Grep for lines with Foo, bar but not baz. Ignore case for bar and baz: =head1 AUTHOR -Copyright (C) 2017-2018 Ole Tange, +Copyright (C) 2017-2023 Ole Tange, http://ole.tange.dk and Free Software Foundation, Inc. @@ -95,7 +97,7 @@ B =cut my $i = 0; -my $add_i = ""; +my @add_X; for(@ARGV) { if($_ eq "-g") { @@ -104,21 +106,18 @@ for(@ARGV) { # -g not an option for grep next; } - if($_ eq "--i") { - # --i = add ignore case to the rest - $opt::i ||= 1; - $add_i = "-i"; - # --i not an option for grep + if($_ =~ /^--(.)$/) { + # --X = add -X to the rest + $opt::X ||= 1; + push @add_X, "-$1"; + # --X not an option for grep next; } - if($add_i) { push @{$cmd[$i]}, $add_i; $add_i = ""; } push @{$cmd[$i]}, $_; if(/^[^-]/) { + # This is not an option + if(@add_X) { unshift @{$cmd[$i]}, @add_X; } $i++; - if($opt::i) { - # If --i: add -i as option - $add_i = "-i"; - } } }