G: added --i
This commit is contained in:
parent
860c780a78
commit
d9d02d7137
23
G/G
23
G/G
|
@ -34,6 +34,11 @@ necessarily on the same line.
|
|||
If a parent dir contains a B<.git> dir B<git grep> is used.
|
||||
|
||||
|
||||
=item B<--i>
|
||||
|
||||
Ignore case for all following options.
|
||||
|
||||
|
||||
=item I<other options>
|
||||
|
||||
All B<grep> options.
|
||||
|
@ -48,6 +53,11 @@ Grep for lines with Foo but not Bar:
|
|||
G Foo -v Bar
|
||||
|
||||
|
||||
Grep for lines with Foo, bar but not baz. Ignore case for bar and baz:
|
||||
|
||||
G Foo --i bar -v baz
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright (C) 2017-2018 Ole Tange,
|
||||
|
@ -85,6 +95,7 @@ B<grep>
|
|||
=cut
|
||||
|
||||
my $i = 0;
|
||||
my $add_i = "";
|
||||
|
||||
for(@ARGV) {
|
||||
if($_ eq "-g") {
|
||||
|
@ -93,9 +104,21 @@ 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
|
||||
next;
|
||||
}
|
||||
if($add_i) { push @{$cmd[$i]}, $add_i; $add_i = ""; }
|
||||
push @{$cmd[$i]}, $_;
|
||||
if(/^[^-]/) {
|
||||
$i++;
|
||||
if($opt::i) {
|
||||
# If --i: add -i as option
|
||||
$add_i = "-i";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ sub version() {
|
|||
print join
|
||||
("\n",
|
||||
"GNU $Global::progname $Global::version",
|
||||
"Copyright (C) 2020 Ole Tange, http://ole.tange.dk and Free Software",
|
||||
"Copyright (C) 2020-2022 Ole Tange, http://ole.tange.dk and Free Software",
|
||||
"Foundation, Inc.",
|
||||
"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>",
|
||||
"This is free software: you are free to change and redistribute it.",
|
||||
|
|
Loading…
Reference in a new issue