summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2019-03-03 17:53:27 +0100
committerLeah Neukirchen <leah@vuxu.org>2019-03-03 17:53:27 +0100
commit244ee73865b924adf9026eb5ff75e6f8f989edc5 (patch)
tree1add2ad94934e9dd81288933d290ad7469aa9160
parent13ceb77f59f5d001ba3e71dff75340278d8a73a8 (diff)
downloadrwc-244ee73865b924adf9026eb5ff75e6f8f989edc5.tar.gz
rwc-244ee73865b924adf9026eb5ff75e6f8f989edc5.tar.xz
rwc-244ee73865b924adf9026eb5ff75e6f8f989edc5.zip
rwc: make -c prefix lines with "+ " v0.2
-rw-r--r--README7
-rw-r--r--rwc.15
-rw-r--r--rwc.c11
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);