diff options
| -rw-r--r-- | stest.1 | 3 | ||||
| -rw-r--r-- | stest.c | 9 |
2 files changed, 10 insertions, 2 deletions
| @@ -13,7 +13,8 @@ stest \- filter a list of files by properties | |||
| 13 | .B stest | 13 | .B stest |
| 14 | takes a list of files and filters by the files' properties, analogous to | 14 | takes a list of files and filters by the files' properties, analogous to |
| 15 | .IR test (1). | 15 | .IR test (1). |
| 16 | Files which pass all tests are printed to stdout. | 16 | Files which pass all tests are printed to stdout. If no files are given, stest |
| 17 | reads files from stdin. | ||
| 17 | .SH OPTIONS | 18 | .SH OPTIONS |
| 18 | .TP | 19 | .TP |
| 19 | .B \-a | 20 | .B \-a |
| @@ -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; | |||
| 17 | int | 18 | int |
| 18 | main(int argc, char *argv[]) { | 19 | main(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 */ |
