ggreer/the_silver_searcher — pull request #166 by syohex (2013-03-03 05:19:51+00:00)
Title: Fix to check piped

I think that it is not enough to check piped by `isatty`.

Sample code is below.
````c
#include
#include

int main (void)
{
if (isatty(STDIN_FILENO)) {
printf("stdin is tty\n");
} else {
printf("stdin is not tty\n");
}

return 0;
}
````

I got following output with terminal emulater
````
% ./isatty.out
stdin is tty
% echo foo | ./isatty.out
stdin is not tty
````

But I got following output with Emacs, because `stdin` is not tty.
````
(call-process-shell-command "./isatty.out" nil t) ;; => stdin is not tty
(call-process-shell-command "echo foo | ./isatty.out" nil t) ;; => stdin is not tty
````

So I think `S_ISFIFO` is better than `isatty`.
````c
#include
#include
#include
#include

int main (void)
{
struct stat st;
int ret;

ret = fstat(STDIN_FILENO, &st);
if (ret != 0) {
perror("stat:");
return 1;
}

if (S_ISFIFO(st.st_mode)) {
printf("stdin is fifo\n");
} else {
printf("stdin is not fifo\n");
}

return 0;
}
````

Terminal emulator
````
% ./stat.out
stdin is not fifo
% echo foo | ./stat.out
stdin is fifo
````

Emacs
````
(call-process-shell-command "./stat.out" nil t) ;; => stdin is not fifo
(call-process-shell-command "echo foo | ./stat.out" nil t) ;; => stdin is fifo
````

I got same result by `S_ISFIFO`.

But this patch changes behavior of `stdin` redirect as below
````
% ag search_word < file
````

Original code searchs only file content, but code applied this patch searchs
under current dictroy(same as `ack`).

Please check this patch, if you have no problems.