Fix piped in input
This commit is contained in:
parent
9d5b9577f7
commit
7fd49c0225
15
bp.c
15
bp.c
@ -673,10 +673,15 @@ int main(int argc, char *argv[])
|
|||||||
options.git_mode = true;
|
options.git_mode = true;
|
||||||
|
|
||||||
int found = 0;
|
int found = 0;
|
||||||
if (options.git_mode) { // Get the list of files from `git --ls-files ...`
|
if (!isatty(STDIN_FILENO) && !argv[0]) {
|
||||||
|
// Piped in input:
|
||||||
|
options.print_filenames = false; // Don't print filename on stdin
|
||||||
|
found += process_file("", pattern, defs);
|
||||||
|
} else if (options.git_mode) {
|
||||||
|
// Get the list of files from `git --ls-files ...`
|
||||||
found = process_git_files(pattern, defs, argc, argv);
|
found = process_git_files(pattern, defs, argc, argv);
|
||||||
} else if (argv[0]) {
|
} else if (argv[0]) {
|
||||||
// Files pass in as command line args:
|
// Files passed in as command line args:
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
if (!argv[1] && !(stat(argv[0], &statbuf) == 0 && S_ISDIR(statbuf.st_mode))) // Don't print filename for single-file matching
|
if (!argv[1] && !(stat(argv[0], &statbuf) == 0 && S_ISDIR(statbuf.st_mode))) // Don't print filename for single-file matching
|
||||||
options.print_filenames = false;
|
options.print_filenames = false;
|
||||||
@ -686,13 +691,9 @@ int main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
found += process_file(argv[0], pattern, defs);
|
found += process_file(argv[0], pattern, defs);
|
||||||
}
|
}
|
||||||
} else if (isatty(STDIN_FILENO)) {
|
} else {
|
||||||
// No files, no piped in input, so use files in current dir, recursively
|
// No files, no piped in input, so use files in current dir, recursively
|
||||||
found += process_dir(".", pattern, defs);
|
found += process_dir(".", pattern, defs);
|
||||||
} else {
|
|
||||||
// Piped in input:
|
|
||||||
options.print_filenames = false; // Don't print filename on stdin
|
|
||||||
found += process_file("", pattern, defs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This code frees up all residual heap-allocated memory. Since the program
|
// This code frees up all residual heap-allocated memory. Since the program
|
||||||
|
Loading…
Reference in New Issue
Block a user