G: added --i

This commit is contained in:
Ole Tange 2022-12-17 22:36:15 +01:00
parent 860c780a78
commit d9d02d7137
3 changed files with 25 additions and 1 deletions

23
G/G
View file

@ -34,6 +34,11 @@ necessarily on the same line.
If a parent dir contains a B<.git> dir B<git grep> is used. 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> =item I<other options>
All B<grep> options. All B<grep> options.
@ -48,6 +53,11 @@ Grep for lines with Foo but not Bar:
G Foo -v 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 =head1 AUTHOR
Copyright (C) 2017-2018 Ole Tange, Copyright (C) 2017-2018 Ole Tange,
@ -85,6 +95,7 @@ B<grep>
=cut =cut
my $i = 0; my $i = 0;
my $add_i = "";
for(@ARGV) { for(@ARGV) {
if($_ eq "-g") { if($_ eq "-g") {
@ -93,9 +104,21 @@ for(@ARGV) {
# -g not an option for grep # -g not an option for grep
next; 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]}, $_; push @{$cmd[$i]}, $_;
if(/^[^-]/) { if(/^[^-]/) {
$i++; $i++;
if($opt::i) {
# If --i: add -i as option
$add_i = "-i";
}
} }
} }

View file

@ -186,7 +186,7 @@ sub version() {
print join print join
("\n", ("\n",
"GNU $Global::progname $Global::version", "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.", "Foundation, Inc.",
"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>", "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.", "This is free software: you are free to change and redistribute it.",

View file

@ -67,6 +67,7 @@ B<G>
=cut =cut
ulimit -u `ulimit -Hu`
find_find_vidlist() { find_find_vidlist() {
# find_find_vidlist(start_dir) # find_find_vidlist(start_dir)
# Find the file .vidlist in . .. ../.. ../../.. etc # Find the file .vidlist in . .. ../.. ../../.. etc