diff --git a/data/Makefile b/data/Makefile deleted file mode 100644 index f378636..0000000 --- a/data/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -all: ; -clean: ; -sane: ; -.PHONY: all clean sane diff --git a/str/str.1 b/str/str.1 index fc0aa96..717ab6a 100644 --- a/str/str.1 +++ b/str/str.1 @@ -16,7 +16,9 @@ Str tests each character in an arbitrary quantity of string arguments against th .SH DIAGNOSTICS -Strexits successfully if all tests pass and unsuccessfully if a test failed. +Str exits successfully if all tests pass and unsuccessfully if a test failed. +.PP +Str will exit unsuccessfully if a string is empty, as none of its contents passed the test. .PP Str will print a message to standard error and exit unsuccessfully if used improperly. diff --git a/str/str.c b/str/str.c index 3099a99..91f15c1 100644 --- a/str/str.c +++ b/str/str.c @@ -31,6 +31,7 @@ static struct { int main(int argc, char *argv[]){ int ctype; int i; + int r; if(argc < 3){ usage: fprintf(stderr, "Usage: %s [type] [string...]\n", @@ -44,10 +45,12 @@ usage: fprintf(stderr, "Usage: %s [type] [string...]\n", goto pass; goto usage; -pass: for(argv += 2; *argv != NULL; ++argv) +pass: for(argv += 2, r = 1; *argv != NULL; ++argv) for(i = 0; argv[0][i] != '\0'; ++i) if(!ctypes[ctype].f(argv[0][i])) return 1; + else + r = 0; - return 0; + return r; }