ack3 icon indicating copy to clipboard operation
ack3 copied to clipboard

Make ack expand globs on Windows

Open xenu opened this issue 6 years ago • 5 comments

C:\Users\xenu>ack foobar *.txt
ack: *.txt: No such file or directory

Windows shells (both cmd.exe and powershell) don't expand globs, applications have to do it on their own. In Perl, it's typically accomplished by calling glob() on each argument, see Win32::Autoglob for an example.

IMHO adding wildcard expansion would significantly improve usability of ack on Windows.

xenu avatar Jan 29 '20 01:01 xenu

Interesting. Fifteen years of ack and nobody's told me that. Hmm.

Mind you, ack is designed so that you rarely specify file names, and specify file types instead.

petdance avatar Jan 29 '20 03:01 petdance

@petdance : "*.txt" - doesn't it remind you FILE TYPE??

WrongBit avatar Mar 05 '20 09:03 WrongBit

Despite amount of "likes" :) I highly recommend to implement such feature. Most typical task is "find me substring in these file types recursively from current dir". I also failed when tried to specify file type thru wildcards and most Windows developers will fail too.

WrongBit avatar Mar 05 '20 09:03 WrongBit

Note that my comment "Interesting. Fifteen years of ack and nobody's told me that." isn't discrediting the comment. I'm just surprised, literally, that it hasn't come up before.

petdance avatar Mar 06 '20 01:03 petdance

I'm not surprised we hadn't heard this. Even I hadn't noticed that we didn't have Globbing for Windows, and I did formerly use ack on Windows some (on my last windows laptop at home, years ago; and at work before my desktop and day-job moved to Texas without me).

  • Many of Ack's users on Windows will have installed BASH and PERL in one package (MKS-TK or CygWin) and will get glob expansion on commandline in BASH, and are used to commands that expect the globbing to be in BASH, and so not complain, it's normal.

  • Ack users, even those in CMD.exe, will usually migrate to using --txt working recursively rather than *.txt except for the rare case that they really really don't want recursion and only want files right here. If *.txt doesn't work, but --txt does, they'll just switch.

HOWEVER.

  • Principle of least surprise says it should DWIM.
  • Being a good tenant of an OS means it should do the globbing on OS where globbing is delegated to the program. When in Rome etc.

(I don't see much downside to globbing under CygWin or on other OS if a "'.txt'" is over quoted. Yeah it's legal to create a file called '.txt' on posix but not a good idea!)

So this would be a good thing to add. Would need new .t files matching our existing --txt tests with "*.txt" on Windows. We can probably do initial testing on POSIX ... just with extra quoting.

n1vux avatar Mar 06 '20 03:03 n1vux