Xinqi Bao's Git
projects
/
dmenu.git
/ commitdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (from parent 1:
32ef0f5
)
stest: restore stream testing
author
Connor Lane Smith <
[email protected]
>
Fri, 9 Dec 2011 10:49:44 +0000
(11:49 +0100)
committer
Connor Lane Smith <
[email protected]
>
Fri, 9 Dec 2011 10:49:44 +0000
(11:49 +0100)
stest.1
patch
|
blob
|
history
stest.c
patch
|
blob
|
history
diff --git
a/stest.1
b/stest.1
index
1f590ec
..
bb48f45
100644
(file)
--- a/
stest.1
+++ b/
stest.1
@@
-13,7
+13,8
@@
stest \- filter a list of files by properties
.B stest
takes a list of files and filters by the files' properties, analogous to
.IR test (1).
.B stest
takes a list of files and filters by the files' properties, analogous to
.IR test (1).
-Files which pass all tests are printed to stdout.
+Files which pass all tests are printed to stdout. If no files are given, stest
+reads files from stdin.
.SH OPTIONS
.TP
.B \-a
.SH OPTIONS
.TP
.B \-a
diff --git
a/stest.c
b/stest.c
index
b4dba64
..
e1dcf36
100644
(file)
--- a/
stest.c
+++ b/
stest.c
@@
-3,6
+3,7
@@
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/stat.h>
@@
-17,7
+18,7
@@
static struct stat old, new;
int
main(int argc, char *argv[]) {
struct dirent *d;
int
main(int argc, char *argv[]) {
struct dirent *d;
- char buf[BUFSIZ];
+ char buf[BUFSIZ]
, *p
;
DIR *dir;
int opt;
DIR *dir;
int opt;
@@
-35,6
+36,12
@@
main(int argc, char *argv[]) {
fprintf(stderr, "usage: %s [-abcdefghlpqrsuwx] [-n file] [-o file] [file...]\n", argv[0]);
exit(2);
}
fprintf(stderr, "usage: %s [-abcdefghlpqrsuwx] [-n file] [-o file] [file...]\n", argv[0]);
exit(2);
}
+ if(optind == argc)
+ while(fgets(buf, sizeof buf, stdin)) {
+ if((p = strchr(buf, '\n')))
+ *p = '\0';
+ test(buf, buf);
+ }
for(; optind < argc; optind++)
if(FLAG('l') && (dir = opendir(argv[optind]))) {
/* test directory contents */
for(; optind < argc; optind++)
if(FLAG('l') && (dir = opendir(argv[optind]))) {
/* test directory contents */