beyondgrep / ack2

**ack 2 is no longer being maintained. ack 3 is the latest version.**
https://github.com/beyondgrep/ack3/
Other
1.48k stars 140 forks source link

Documentation is incorrect for .ackrc locations #518

Closed jgbishop closed 9 years ago

jgbishop commented 9 years ago

The ackrc location semantics section of the ack manual seems incorrect to me. It states that user .ackrc files can be placed in <C:\Users\$USER\AppData\Roaming>, but this does not work! I found that if I placed my .ackrc file in my %USERPROFILE% folder (C:\Users\$USERNAME), ack finds the file as expected.

jgbishop commented 9 years ago

Hmm. On second look, even that folder doesn't work for me. I must have something misconfigured ... let me look into this again.

jgbishop commented 9 years ago

OK, so on second look, it appears that Windows expects the file to be named ackrc not .ackrc. This seems like a bug to me (I guess either should be allowed). The documentation that I linked to isn't consistent on which filename to use. Some of the examples show it with the period, others show it without. Either standardizing this, or making it clear what options work where, would be useful I think.

Should I open a separate issue for Windows not working with .ackrc? This issue is specifically about the documentation.

hoelzro commented 9 years ago

I'm not sure if .ackrc works on Windows; that's why we also look for _ackrc. Is that what you meant by ackrc? The documentation should probably reflect the fact that .ackrc doesn't work on Windows.

hoelzro commented 9 years ago

@jgbishop Regarding a separate issue for .ackrc on Windows, I don't know why it doesn't work, but I'm guessing there's a reason _ackrc was introduced. If you can determine what the reason is, or whether it's still valid, we can see about either enhancing the docs or allowing .ackrc on Windows.

jgbishop commented 9 years ago

So I've done a little more research, and I seem to be wrong about things not working. They're just inconsistent. Here's what I see: in Unix-like environments, ack checks the following locations in order:

  1. /etc/ackrc (no leading period for this filename)
  2. $ENV{'ACKRC'} (if it exists)
  3. $HOME/.ackrc (if $ENV{'ACKRC'} doesn't exist ... a leading period for this one)
  4. cwd()/.ackrc or cwd()/_ackrc (leading period or underscore)

Windows is similar, though the order is slightly different

  1. Win32::CSIDL_COMMON_APPDATA()/ackrc (no leading period; resolves to C:\ProgramData in Win7)
  2. Win32::CSIDL_APPDATA()/ackrc (no leading period; resolves to C:\Users\$User\AppData\Roaming in Win7)
  3. $ENV{'ACKRC'} (if it exists)
  4. cwd()/.ackrc or cwd()/_ackrc (leading period or underscore)

I guess my confusion stemmed from the fact that there was no consistency with the leading periods, underscores, or lack thereof. The OCD in me says that the file name should probably be the same everywhere, but I'm no expert on the etiquette for dot-file name syntax. Regardless, I've improved the documentation for this section a little bit, and hope to have a pull request for that available shortly.

hoelzro commented 9 years ago

This sort of inconsistency is common in the Unix word; ex. Vim checks for /etc/vimrc and ~/.vimrc, zsh checks /etc/zshrc and ~/.zshrc, etc. It's probably a little odd shoe-horning it into the Windows world, but I think one of ack's goals (at least formerly) was to serve as a sort of gateway for Windows folks into Unix tools.

jgbishop commented 9 years ago

This sort of inconsistency is common in the Unix word

In that case, no logic needs to be changed then. Like I say, I'm no expert. The documentation just tripped me up a little, hence my minor fixes. Thanks!

jgbishop commented 9 years ago

I'll go ahead and close this issue, since #519 was merged.