beyondgrep / ack3

ack is a grep-like search tool optimized for source code.
https://beyondgrep.com/
Other
705 stars 66 forks source link

ack returns error when --sort-files flag is set in .ackrc #347

Closed erawhctim closed 3 years ago

erawhctim commented 3 years ago

--version output:

ack v3.3.1 (standalone version)
Running under Perl v5.30.2 at /usr/bin/perl

running macOS 11.4

when my .ackrc looks like this:

--sort-files

or

--sort-files=true

Running commands via ack (e.g. ack "test") returns this error: Unknown option: sort−files Adding the --sort-files flag manually (e.g. ack "test" --sort-files) works fine.

What am I missing?

petdance commented 3 years ago

I don't know. I have --sort-files in my ~/.ackrc, too.

Did you cut & paste the --sort-files from somewhere that might have made the hyphens something other than normal old hyphens? Try deleting the --sort-files line from your ~/.ackrc and retype it manually and see if that does it.

petdance commented 3 years ago

I think that's it. The hyphen in sort-files is an en-dash or an em-dash. I cut and pasted your message from above and did a hexdump on it.

$ cat > foo
Unknown option: sort−files
$ cat foo
Unknown option: sort−files
$ xxd foo
00000000: 556e 6b6e 6f77 6e20 6f70 7469 6f6e 3a20  Unknown option:
00000010: 736f 7274 e288 9266 696c 6573 0a         sort...files.

See that between "sort" and "files" there are three bytes.

I manually edited foo and redumped and it looks like this:

$ vim foo
$ xxd foo
00000000: 556e 6b6e 6f77 6e20 6f70 7469 6f6e 3a20  Unknown option:
00000010: 736f 7274 2d66 696c 6573 0a              sort-files.
erawhctim commented 3 years ago

oh wow, yeah that was definitely it. Sorry about that! (and thanks for the help 🙂)

petdance commented 3 years ago

You're welcome. I'm glad that's all it was. 👍