summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2006-09-20 01:06:56 +0200
committerTobias Klauser <tklauser@xenon.tklauser.home>2006-09-20 01:06:56 +0200
commit1399781d572b8779ffedd2fe3ed3a35d834fa41d (patch)
tree97853183c1e473e8cfae1383a9189a536ee366d5
parent06fb7c3eb59368013598947aa8ec90fda7f4c612 (diff)
Print pretty name for stdin in verbose mode
-rw-r--r--inotail.c11
1 files 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;
}