[hackers] [dmenu] stest: restore stream testing || Connor Lane Smith
changeset: 473:424bff81a158
branch: stest
tag: tip
parent: 471:60d97462ff9d
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Fri Dec 09 11:49:44 2011 +0100
files: stest.1 stest.c
description:
stest: restore stream testing
diff -r 60d97462ff9d -r 424bff81a158 stest.1
--- a/stest.1 Sun Nov 27 23:40:48 2011 +0100
+++ b/stest.1 Fri Dec 09 11:49:44 2011 +0100
_AT_@ -13,7 +13,8 @@
.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
diff -r 60d97462ff9d -r 424bff81a158 stest.c
--- a/stest.c Sun Nov 27 23:40:48 2011 +0100
+++ b/stest.c Fri Dec 09 11:49:44 2011 +0100
_AT_@ -3,6 +3,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
_AT_@ -17,7 +18,7 @@
int
main(int argc, char *argv[]) {
struct dirent *d;
- char buf[BUFSIZ];
+ char buf[BUFSIZ], *p;
DIR *dir;
int opt;
_AT_@ -35,6 +36,12 @@
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 */
Received on Fri Dec 09 2011 - 11:50:02 CET
This archive was generated by hypermail 2.3.0
: Fri Dec 09 2011 - 12:00:08 CET