Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silent hanging on encountering a ./- file #272

Open
Smylers opened this issue Apr 30, 2015 · 3 comments
Open

Silent hanging on encountering a ./- file #272

Smylers opened this issue Apr 30, 2015 · 3 comments
Labels

Comments

@Smylers
Copy link

Smylers commented Apr 30, 2015

If ack encounters a file called - in the current directory then it silently hangs for ever.

It seems that the file - is being treated as though it were a command-line argument -, which would indicate to read from standard input (and would indeed correctly cause ack to hang if there weren't anything on stdin). But a file called ./- is unambiguously a file; it isn't a command-line argument, and it isn't stdin.

Steps to reproduce. This works as expected:

$ mkdir bug_551
$ cd bug_551
$ echo aiieee > Batman.txt
$ ack i
Batman.txt
1:aiieee

Creating ./- causes the hang:

$ touch ./-
$ ack i

Explicitly listing the files to search avoids ./- getting in the way:

$ ack i *txt
aiieee

Bug #269 is sort-of the opposite of this, but they may overlap: both are influenced by ./-.

@Smylers
Copy link
Author

Smylers commented Apr 30, 2015

A better demo that ./- is actually making ack read from stdin:

$ echo zam > ./-
$ echo thwapp | ack --nofilter a
-
1:thwapp

Batman.txt
1:aiieee

See that ack displays the “thwapp” from stdin, not the “zam” from ./-.

@petdance
Copy link
Collaborator

What does grep do in a similar situation?

@Smylers
Copy link
Author

Smylers commented Apr 30, 2015

What does grep do in a similar situation?

It just treats a file called - that it encounters on the file system as it would any other file:

$ echo thwapp | grep -r a
-:zam
Batman.txt:aiieee

But a - passed as an argument is treated as stdin:

$ echo thwapp | grep -r a -
thwapp

And an argument - can be mixed with other file/directory arguments, keeping stdin distinct from ./-:

$ echo thwapp | grep -r a - .
(standard input):thwapp
./-:zam
./Batman.txt:aiieee

@petdance petdance transferred this issue from beyondgrep/ack2 Sep 28, 2019
@petdance petdance added the bug label Sep 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants