-g, case sensitivity, and ack2

93 views
Skip to first unread message

Rob Hoelz

unread,
May 1, 2012, 4:22:03 AM5/1/12
to ack-...@googlegroups.com
Hello everyone,

I often find myself typing something like the following:

ack --perl -g -i widget

to find all Perl files with the word 'widget' in the name, ignoring case.  However, this doesn't work in ack 1.x!  So Andy and I were planning on adding this
to ack2, but then I remembered that the -G option exists.  When using -G, -i still applies to the regex for searching files.  So, the way I see it, we have four options:

  1. Get rid of -G.
  2. Cancel this idea (-g + -i).
  3. Make -i apply to the file regex in -g (as in this idea), and make -i apply to the file contents regex when using -G.
  4. Add a new flag, -I or something, to differentiate between the two.

What are the community's thoughts on this?  Does anyone make use of -G?  Who else would benefit from -g + -i?

Thanks,

Rob

Elliot Shank

unread,
May 1, 2012, 7:30:32 AM5/1/12
to ack-...@googlegroups.com, Rob Hoelz
On 5/1/12 3:22 AM, Rob Hoelz wrote:
> 1. Get rid of -G.

I use this. Please don't remove it.

> 2. Cancel this idea (-g + -i).

Second choice.

> 3. Make -i apply to the file regex in -g (as in this idea), *and* make -i apply to the file contents regex when using -G.

Makes it even more counterintuitive if you need to turn off case sensitivity in one or the other. "ack -g -i '(?-i)whatever)' something".

> 4. Add a new flag, -I or something, to differentiate between the two.

First choice. Although gnu grep has

-I equivalent to --binary-files=without-match

Don't know that that's that big of a deal.

David Romani

unread,
May 1, 2012, 7:30:46 AM5/1/12
to ack-...@googlegroups.com
Rob

My two cents: I use -G on a fairly regular basis when I am doing a targeted search into a known file name and because it is known case sensitivity is usually not important.

If I have to tweak case on -G i usually resort to a file glob in the argument to -G, e.g, [cC]onfig.ini, but again the the universe of variations is limited.

My vote would be a new flag.


David Romani
Senior Linux System Administrator
Library Systems / University Libraries
The University of North Carolina at Chapel Hill
> --
> You received this message because you are subscribed to the Google Groups "ack dev/users" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/ack-users/-/qbga-5xIMyUJ.
> To post to this group, send email to ack-...@googlegroups.com.
> To unsubscribe from this group, send email to ack-users+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ack-users?hl=en.

Rob Hoelz

unread,
May 1, 2012, 7:50:41 AM5/1/12
to ack-...@googlegroups.com
Ok, I figured people would be using -G, but I just wanted to double check. =)  My preference is also to add a new flag, but I don't know if that would overcomplicate things, and I don't know what flag would be best to use.
> To unsubscribe from this group, send email to ack-users+unsubscribe@googlegroups.com.

Tom Burger

unread,
May 1, 2012, 9:05:09 AM5/1/12
to ack-...@googlegroups.com
I use -G a lot and it would be useful to include case-insensitive searches for this.  I think it would be cleaner to introduce a new longer option like --ignore-case-file.  It could even apply to usage outside of -G. You could even extend the full list of searching options to "-file" versions:

These commands would apply to any FILE PATTERN arguments.

--ignore-case-file              Ignore case distinctions in FILE PATTERN
--[no]smart-case-file         Ignore case distinctions in FILE PATTERN,
                                      only if FILE PATTERN contains no upper case
                                      Ignored if -ignore-case-file is specified
--invert-match-file             Invert match: select non-matching files
--word-regexp-file             Force FILE PATTERN to match only whole words
--literal-file                       Quote all metacharacters; FILE PATTERN is literal

-Tom

To view this discussion on the web visit https://groups.google.com/d/msg/ack-users/-/Idzi1-iQqFMJ.

To post to this group, send email to ack-...@googlegroups.com.
To unsubscribe from this group, send email to ack-users+...@googlegroups.com.

Andy Lester

unread,
May 1, 2012, 10:23:48 AM5/1/12
to ack-...@googlegroups.com

On May 1, 2012, at 8:05 AM, Tom Burger wrote:

--ignore-case-file              Ignore case distinctions in FILE PATTERN
--[no]smart-case-file         Ignore case distinctions in FILE PATTERN,
                                      only if FILE PATTERN contains no upper case
                                      Ignored if -ignore-case-file is specified
--invert-match-file             Invert match: select non-matching files
--word-regexp-file             Force FILE PATTERN to match only whole words
--literal-file                       Quote all metacharacters; FILE PATTERN is literal

Stuff like that makes me think that -G is overreaching, and makes me wish we didn't have it in the first place. :-(

I'm wondering if we should support regexy sort of things on the pattern, as in:

ack -G /foo.+bar/i string-to-find

and have Perl just Do The Right Thing with that.

xoa

Elliot Shank

unread,
May 1, 2012, 9:56:57 PM5/1/12
to ack-...@googlegroups.com, Andy Lester
On 5/1/12 9:23 AM, Andy Lester wrote:
> I'm wondering if we should support regexy sort of things on the pattern, as in:
>
> ack -G /foo.+bar/i string-to-find
>
> and have Perl just Do The Right Thing with that.

That is unlikely to be The Right Thing given that -G works on paths and "/" is the *nix directory delimiter.

Ted Trela

unread,
May 3, 2012, 4:10:19 PM5/3/12
to ack-...@googlegroups.com
Hi - I stumbled across ack today and installed and this was the first thing I tried and bumped into.

ack --perl -g -i widget

Certainly some of the extended command line switches as suggested would be a nice thing to stick into the ackrc file.
e.g.    --ignore-case-file              Ignore case distinctions in FILE PATTERN

Perhaps known, but a simple workaround I found was to invoke Perl's extended pattern syntax http://perldoc.perl.org/perlre.html#Extended-Patterns
and this collected up all the files with case insensitivity.  

e.g.   ack --perl -g '(?i)widget' 

Ted.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages