diff options
author | Duncaen <mail@duncano.de> | 2017-05-30 01:40:04 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2017-05-30 12:49:01 +0200 |
commit | 43c62fd5e9c934ceb5559d464789ca161682a358 (patch) | |
tree | 22be273a7436f2e8cf930cffe2b0d788b2146d46 | |
parent | e0090177d10e5d2a4b951c71d1f14d4ec6d3aa2a (diff) | |
download | rwc-43c62fd5e9c934ceb5559d464789ca161682a358.tar.gz rwc-43c62fd5e9c934ceb5559d464789ca161682a358.tar.xz rwc-43c62fd5e9c934ceb5559d464789ca161682a358.zip |
rwc: add e flag to exit after the first reported change
Closes: #1 [via git-merge-pr]
-rw-r--r-- | rwc.1 | 4 | ||||
-rw-r--r-- | rwc.c | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/rwc.1 b/rwc.1 index 57c9d22..cfd7714 100644 --- a/rwc.1 +++ b/rwc.1 @@ -6,7 +6,7 @@ .Nd report when changed .Sh SYNOPSIS .Nm -.Op Fl 0dp +.Op Fl 0dep .Op Ar path\ ... .Sh DESCRIPTION .Nm @@ -34,6 +34,8 @@ Also detect file deletion. In this case, deleted files are prefixed by .Sq Li "- " (that is, a dash and a space). +.It Fl e +Exit after the first reported change. .It Fl p Pipe mode; don't report changes while the standard output pipe is not empty. diff --git a/rwc.c b/rwc.c index 664fa1c..94fcdc2 100644 --- a/rwc.c +++ b/rwc.c @@ -27,6 +27,7 @@ char ibuf[8192]; int ifd; int dflag; +int eflag; int pflag; char input_delim = '\n'; @@ -93,13 +94,14 @@ main(int argc, char *argv[]) argv0 = argv[0]; - while ((c = getopt(argc, argv, "0dp")) != -1) + while ((c = getopt(argc, argv, "0dep")) != -1) switch(c) { case '0': input_delim = 0; break; case 'd': dflag = IN_DELETE | IN_DELETE_SELF; break; + case 'e': eflag++; break; case 'p': pflag++; break; default: - fprintf(stderr, "Usage: %s [-0dp] [PATH...]\n", argv0); + fprintf(stderr, "Usage: %s [-0dep] [PATH...]\n", argv0); exit(2); } @@ -185,6 +187,8 @@ from_stdin: name, input_delim); fflush(stdout); + if (eflag) + exit(0); } } } |