diff options
Diffstat (limited to 'src/execline/forstdin.c')
-rw-r--r-- | src/execline/forstdin.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/execline/forstdin.c b/src/execline/forstdin.c index 95ec4d5..7979811 100644 --- a/src/execline/forstdin.c +++ b/src/execline/forstdin.c @@ -3,6 +3,7 @@ #include <sys/types.h> #include <string.h> #include <errno.h> + #include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/buffer.h> @@ -17,7 +18,7 @@ #include <execline/config.h> #include <execline/execline.h> -#define USAGE "forstdin [ -p | -o okcode,okcode,... | -x breakcode,breakcode,... ] [ -n ] [ -C | -c ] [ -0 | -d delim ] var command..." +#define USAGE "forstdin [ -p | -o okcode,okcode,... | -x breakcode,breakcode,... ] [ -e eofcode ] [ -n ] [ -C | -c ] [ -0 | -d delim ] var command..." #define dieusage() strerr_dieusage(100, USAGE) static genalloc pids = GENALLOC_ZERO ; /* pid_t */ @@ -51,12 +52,13 @@ int main (int argc, char const **argv, char const *const *envp) size_t nbc = 0 ; unsigned short okcodes[256] ; int crunch = 0, chomp = 0, not = 1 ; + unsigned short eofcode = 0 ; PROG = "forstdin" ; { subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "pnCc0d:o:x:", &l) ; + int opt = subgetopt_r(argc, argv, "pnCc0d:o:x:e:", &l) ; if (opt == -1) break ; switch (opt) { @@ -79,6 +81,9 @@ int main (int argc, char const **argv, char const *const *envp) not = 1 ; if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; break ; + case 'e' : + if (!ushort_scan(l.arg, &eofcode)) dieusage() ; + break ; default : dieusage() ; } } @@ -154,5 +159,5 @@ int main (int argc, char const **argv, char const *const *envp) if (!pids.len) break ; sig_pause() ; } - return 0 ; + return eofcode ; } |