From 1399781d572b8779ffedd2fe3ed3a35d834fa41d Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 20 Sep 2006 01:06:56 +0200 Subject: Print pretty name for stdin in verbose mode --- inotail.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/inotail.c b/inotail.c index 635838d..06277f0 100644 --- a/inotail.c +++ b/inotail.c @@ -64,11 +64,16 @@ static void setup_file(struct file_struct *f) f->i_watch = -1; } -static void write_header(const char *filename) +static char *pretty_name(char *filename) +{ + return (strncmp(filename, "-", 1) == 0) ? "standard input" : filename; +} + +static void write_header(char *filename) { static unsigned short first_file = 1; - fprintf(stdout, "%s==> %s <==\n", (first_file ? "" : "\n"), filename); + fprintf(stdout, "%s==> %s <==\n", (first_file ? "" : "\n"), pretty_name(filename)); first_file = 0; } @@ -126,6 +131,8 @@ static int bytes_to_offset(struct file_struct *f, int n_lines) static int tail_pipe(struct file_struct *f) { dprintf(" Trying to tail from '%s'\n", f->name); + if (verbose) + write_header(f->name); return 0; } -- cgit v1.2.3-54-g00ecf