diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2006-09-20 01:06:56 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@xenon.tklauser.home> | 2006-09-20 01:06:56 +0200 |
commit | 1399781d572b8779ffedd2fe3ed3a35d834fa41d (patch) | |
tree | 97853183c1e473e8cfae1383a9189a536ee366d5 | |
parent | 06fb7c3eb59368013598947aa8ec90fda7f4c612 (diff) |
Print pretty name for stdin in verbose mode
-rw-r--r-- | inotail.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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; } |