From 244ee73865b924adf9026eb5ff75e6f8f989edc5 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sun, 3 Mar 2019 17:53:27 +0100 Subject: rwc: make -c prefix lines with "+ " --- README | 7 ++++--- rwc.1 | 5 ++++- rwc.c | 11 ++++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/README b/README index a06a16a..345cb99 100644 --- a/README +++ b/README @@ -20,9 +20,10 @@ DESCRIPTION filenames seperated by NUL bytes. -c Detect all file creations, including open(2) with O_CREAT, - mkdir(2), link(2), symlink(2), and bind(2). This has the side- - effect of printing files twice that are created and immediately - changed after. + mkdir(2), link(2), symlink(2), and bind(2). In this case, + created files are prefixed by ‘+ ’ (that is, a plus and a space). + This option has the side-effect of printing files twice that are + created and immediately changed after. -d Also detect file deletion. In this case, deleted files are prefixed by ‘- ’ (that is, a dash and a space). diff --git a/rwc.1 b/rwc.1 index c793b0c..6a84dee 100644 --- a/rwc.1 +++ b/rwc.1 @@ -39,7 +39,10 @@ with .Xr symlink 2 , and .Xr bind 2 . -This has the side-effect of printing files twice +In this case, created files are prefixed by +.Sq Li "+ " +(that is, a plus and a space). +This option has the side-effect of printing files twice that are created and immediately changed after. .It Fl d Also detect file deletion. diff --git a/rwc.c b/rwc.c index c828644..43ea95a 100644 --- a/rwc.c +++ b/rwc.c @@ -187,11 +187,12 @@ from_stdin: if (n > 0) break; } - printf("%s%s%c", - (ev->mask & (IN_DELETE | IN_MOVED_FROM) ? - "- " : ""), - name, - input_delim); + const char *mark = ""; + if (ev->mask & (IN_DELETE | IN_MOVED_FROM)) + mark = "- "; + else if (ev->mask & IN_CREATE) + mark = "+ "; + printf("%s%s%c", mark, name, input_delim); fflush(stdout); if (eflag) exit(0); -- cgit 1.4.1