ref: 84cd9e7d14ea8a168434aa222b8407220cd724fa
parent: b3e19782a8b46d9479b9961f9442af70efe629b3
author: kvik <[email protected]>
date: Mon Jul 13 12:06:02 EDT 2020
Add the -1 flag for running once and exiting This lets us block waiting until a file changes watch -1 -e changeme exit
--- a/watch.c
+++ b/watch.c
@@ -14,6 +14,7 @@
char pwd[1024];
int period = 1000;
int noregroup = 0;
+int once = 0;
List *expl;
List *filel;
@@ -192,6 +193,8 @@
break;
case 'G':
noregroup = 1; break;
+ case '1':
+ once = 1; break;
default: usage();
}ARGEND;
if(expl == nil)
@@ -205,5 +208,6 @@
for(;;){
watch();
rc(cmd);
+ if(once) exits(nil);
}
}