aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Lane Smith <cls@lubutu.com>2011-12-09 11:49:44 +0100
committerConnor Lane Smith <cls@lubutu.com>2011-12-09 11:49:44 +0100
commit6b1d658d1224cd108d64a6c340d47b66ad99816d (patch)
tree13c2e02462f2a26a067d3309f3c049c126b29471
parent32ef0f5662bfe8b8891ba6341d3a27818fb55508 (diff)
stest: restore stream testing
-rw-r--r--stest.13
-rw-r--r--stest.c9
2 files changed, 10 insertions, 2 deletions
diff --git a/stest.1 b/stest.1
index 1f590ec..bb48f45 100644
--- a/stest.1
+++ b/stest.1
@@ -13,7 +13,8 @@ stest \- filter a list of files by properties
13.B stest 13.B stest
14takes a list of files and filters by the files' properties, analogous to 14takes a list of files and filters by the files' properties, analogous to
15.IR test (1). 15.IR test (1).
16Files which pass all tests are printed to stdout. 16Files which pass all tests are printed to stdout. If no files are given, stest
17reads files from stdin.
17.SH OPTIONS 18.SH OPTIONS
18.TP 19.TP
19.B \-a 20.B \-a
diff --git a/stest.c b/stest.c
index b4dba64..e1dcf36 100644
--- a/stest.c
+++ b/stest.c
@@ -3,6 +3,7 @@
3#include <stdbool.h> 3#include <stdbool.h>
4#include <stdio.h> 4#include <stdio.h>
5#include <stdlib.h> 5#include <stdlib.h>
6#include <string.h>
6#include <unistd.h> 7#include <unistd.h>
7#include <sys/stat.h> 8#include <sys/stat.h>
8 9
@@ -17,7 +18,7 @@ static struct stat old, new;
17int 18int
18main(int argc, char *argv[]) { 19main(int argc, char *argv[]) {
19 struct dirent *d; 20 struct dirent *d;
20 char buf[BUFSIZ]; 21 char buf[BUFSIZ], *p;
21 DIR *dir; 22 DIR *dir;
22 int opt; 23 int opt;
23 24
@@ -35,6 +36,12 @@ main(int argc, char *argv[]) {
35 fprintf(stderr, "usage: %s [-abcdefghlpqrsuwx] [-n file] [-o file] [file...]\n", argv[0]); 36 fprintf(stderr, "usage: %s [-abcdefghlpqrsuwx] [-n file] [-o file] [file...]\n", argv[0]);
36 exit(2); 37 exit(2);
37 } 38 }
39 if(optind == argc)
40 while(fgets(buf, sizeof buf, stdin)) {
41 if((p = strchr(buf, '\n')))
42 *p = '\0';
43 test(buf, buf);
44 }
38 for(; optind < argc; optind++) 45 for(; optind < argc; optind++)
39 if(FLAG('l') && (dir = opendir(argv[optind]))) { 46 if(FLAG('l') && (dir = opendir(argv[optind]))) {
40 /* test directory contents */ 47 /* test directory contents */