Ack has different result on bash and tcsh

11 views
Skip to first unread message

phulien

unread,
Aug 16, 2017, 9:42:35 AM8/16/17
to ack users
Hi,

[anonymous/Desktop/test] -> echo "a test string" > test_file
[anonymous/Desktop/test] -> echo $0
tcsh
[anonymous/Desktop/test] -> ack test
test_file
1:a test string
[anonymous/Desktop/test] -> bash
~/Desktop/test> echo $0
bash
~/Desktop/test> ack test
~/Desktop/test> 

AS you can see that when I search "test" in tcsh shell, ack returns correctly. But when I switch to bash shell, ack returns nothing.
Can anybody suggest what I should do in this case?

Andy Lester

unread,
Aug 16, 2017, 10:49:23 AM8/16/17
to ack-...@googlegroups.com

On Aug 16, 2017, at 1:07 AM, phulien <lien...@gmail.com> wrote:

AS you can see that when I search "test" in tcsh shell, ack returns correctly. But when I switch to bash shell, ack returns nothing.
Can anybody suggest what I should do in this case?

Are you running the same ack executable each time?  What does “which ack” say in each case?

What does ack —version say in each case?

Bill Ricker

unread,
Aug 16, 2017, 12:24:34 PM8/16/17
to ack-...@googlegroups.com
You are correct to expect no difference !

> Are you running the same ack executable each time? What does “which ack”
> say in each case?
>
> What does ack —version say in each case?


1. Indeed yes, "which" and "ack --version" are great diagnostics.
They could nail this. If bash's PATH has ack1 ahead of ack2, this
would be the expected result, ack1 would require a -a or -u flag to
find a text file without extension or shebang, but ack2 reversed that
behavior.


Another couple of diagnostics to try in both shells and report results of --


2. While I am a assuming they are in the *same* $HOME directory, let
us "Trust but Verify"(*) as Gorbachev taught us to say:

If one see a ackrc with a restricted --type and the other doesn't, it
would also produce this result.
We want to double-check that they would use the same .ackrc.
And are they actually on the same system?

uname -a; ls -d $HOME /etc/ackrc $HOME/.ackrc ./[._]ackrc

eg for me,

uname -a; ls -d $HOME /etc/ackrc $HOME/.ackrc ./[._]ackrc
Linux islay 4.4.0-91-generic #114-Ubuntu SMP Tue Aug 8 11:56:56 UTC
2017 x86_64 x86_64 x86_64 GNU/Linux
ls: cannot access '/etc/ackrc': No such file or directory
ls: cannot access './[._]ackrc': No such file or directory
/home/wdr /home/wdr/.ackrc

(If not cd $HOME, actually need to check every .. to $HOME, but your
example shows $HOME so that's ok.)


(*) Which really _is_ funnier in the original Russian:
"Доверяй, но проверяй"
Doveryai, no proveryai
since it rhymes!



3. Check if ack is getting options from .bash_rc or one of the other
bash-ish dot-files ; compare what options ack is using
(e.g. ACK_OPTIONS='--type=perl' or most any other would skip the file)

env | ack 'ACK|PERL' # maybe 'printenv |' on some csh but should work as is
ack --dump

# in modern bash, you can do both at once to compare and only report differences
diff <(ack -f) <(csh -c "ack -f")
diff <(ack --dump) <(csh -c "ack --dump")

[ I get no differences, but that's no surprise, i haven't touched a
.cshrc in very long time. ]

4. Final debug is "ack -f" , it will list all files it thinks are eligible.

ack -f # in each
# or
diff <(ack -f) <(csh -c "ack -f")



--
Bill Ricker
bill....@gmail.com
https://www.linkedin.com/in/n1vux
Reply all
Reply to author
Forward
0 new messages