aboutsummaryrefslogtreecommitdiff
path: root/bp.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-08-25 13:15:05 -0700
committerBruce Hill <bruce@bruce-hill.com>2021-08-25 13:15:05 -0700
commit9db5e91781b71939fd3cd9dd0e8e922e7d52e449 (patch)
treef5dd2802fd6df5af443a0872eef09eecc78f483d /bp.c
parentd7e18968bb92b853ab8eb691e89196e5e2e6f5db (diff)
Only print filenames when there are multiple files
Diffstat (limited to 'bp.c')
-rw-r--r--bp.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/bp.c b/bp.c
index 6243fd2..b1ae071 100644
--- a/bp.c
+++ b/bp.c
@@ -530,6 +530,8 @@ int main(int argc, char *argv[])
} else if (argv[0]) {
// Files pass in as command line args:
struct stat statbuf;
+ if (!argv[1]) // Don't print filename for single-file matching
+ options.print_filenames = false;
for ( ; argv[0]; argv++) {
if (stat(argv[0], &statbuf) == 0 && S_ISDIR(statbuf.st_mode)) // Symlinks are okay if manually specified
found += process_dir(defs, argv[0], pattern);
@@ -541,6 +543,7 @@ int main(int argc, char *argv[])
found += process_dir(defs, ".", pattern);
} else {
// Piped in input:
+ options.print_filenames = false; // Don't print filename on stdin
found += process_file(defs, "", pattern);
}
if (options.mode == MODE_JSON) printf("]\n");