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

- not treated as stdin #269

Open
rdpate opened this issue Oct 10, 2014 · 1 comment
Open

- not treated as stdin #269

rdpate opened this issue Oct 10, 2014 · 1 comment

Comments

@rdpate
Copy link

rdpate commented Oct 10, 2014

Because File::Next only returns existing files, there's no way to use "-" interpreted as stdin -- it gets filtered out before ack gets to see it (except see notes 1-2 below).

Example:

$ cat file
xbyz
$ ack b. - <file  # bug
$ # expected was to read stdin and find a match
$ touch ./-  # watch what happens
$ ack b. - <file  # as expected, but for wrong reasons, note-1
xbyz
$ ack b. ./-  # as expected, note-2
$

Notes 1-2 show that ack b. - <file is testing ./- for file existance, but reading stdin.

Possible fixes are changing the sort order from that specfied on the command line (so that you can pull out "-" before File::Next sees it), which is undesirable, or changing File::Next (because of possible name sorting, I couldn't see how to do this otherwise), or maybe something much more exotic with how File::Next is invoked (I looked hard at this first).

Tested against http://beyondgrep.com/ack-2.14-single-file on Ubuntu 14.04.

@rdpate
Copy link
Author

rdpate commented Oct 11, 2014

Related test case for above notes 1-2:

$ ls  # start with empty directory
$ echo abcd | ack b. --nofilter  # nothing, as expected
$ echo xbyz >./-
$ echo abcd | ack b. --nofilter  # bug, expected "xbyz" instead of "abcd"
-
1:abcd
$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants