From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: From: "Steve Simon" Date: Tue, 19 Apr 2005 10:07:36 +0100 To: 9fans@cse.psu.edu MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-nchbywsybpbaabsbzyrgtytyqm" Subject: [9fans] watch Topicbox-Message-UUID: 3d15f28c-ead0-11e9-9d60-3106f5b1d025 This is a multi-part message in MIME format. --upas-nchbywsybpbaabsbzyrgtytyqm Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit watch and wrapper that I use attached. -Steve --upas-nchbywsybpbaabsbzyrgtytyqm Content-Disposition: attachment; filename=revu Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit #!/bin/rc cmd=`{doctype $*} while(){ $cmd | proof & watch $* > /dev/null && slay proof | rc } --upas-nchbywsybpbaabsbzyrgtytyqm Content-Disposition: attachment; filename=watch.c Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit /* watch.c - await first file is modified, then cat all files */ #include #include void main(int argc, char *argv[]) { char buf[4096]; int fd, i, n; Dir *ods, *ds; if (argc != 2){ fprint(2, "usage: await \n"); exits("usage"); } if ((ods = dirstat(argv[1])) == nil) sysfatal("%s - cannot stat\n", argv[1]); while(1){ sleep(1); if ((ds = dirstat(argv[1])) == nil) sysfatal("%s cannot stat %r\n", argv[1]); if (ds->mtime > ods->mtime) break; free(ds); } for (i = 1; i < argc; i++){ if ((fd = open(argv[i], OREAD)) == -1) fprint(2, "%s cannot open - %r\n", argv[i]); while((n = read(fd, buf, sizeof(buf))) > 0) if (write(1, buf, n) != n) sysfatal("%s write failed - %r\n", argv[i]); close(fd); } exits(0); } --upas-nchbywsybpbaabsbzyrgtytyqm--