From 680b08a9d69fcb3582203ca5e1e6f0ba88fea9e0 Mon Sep 17 00:00:00 2001
From: Laurent Bercot
Date: Tue, 24 Nov 2020 11:26:35 +0000
Subject: Better forstdin
No need for the complexity: the important distinction is between
"eof after reading something" and "eof right away". 0 is a natural
fit for eof after some data, and 1 is a natural fit for immediate eof.
Anything else can be scripted around this.
---
doc/forstdin.html | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
(limited to 'doc/forstdin.html')
diff --git a/doc/forstdin.html b/doc/forstdin.html
index c7cc3d4..44939fe 100644
--- a/doc/forstdin.html
+++ b/doc/forstdin.html
@@ -30,7 +30,7 @@ run another program.
- forstdin [ -p | -o okcodes | -x breakcodes ] [ -e eofcode ] [ -n ] [ -C | -c ] [ -0 | -d delim ] variable loop...
+ forstdin [ -p | -o okcodes | -x breakcodes ] [ -E firsteofcode ] [ -e eofcode ] [ -n ] [ -C | -c ] [ -0 | -d delim ] variable loop...
@@ -39,7 +39,8 @@ run another program.
- For every argument x in the split output,
forstdin runs loop... as a child process, with
variable=x added to its environment.
- - forstdin then exits 0.
+
- forstdin then exits 0 if it has read something on stdin,
+and 1 if it hasn't read anything.
Options
@@ -63,8 +64,10 @@ not listed in okcodes, forstdin will exit immediately with an
option, but with inverted meaning - the listed exit codes are codes
that will make forstdin break the loop and exit, and the unlisted exit
codes will make it keep looping.
- -e eofcode : if forstdin reads EOF,
-exit eofcode. Default is 0.
+ -E firsteofcode : if forstdin encounters
+EOF on its first attempt to read data, exit firsteofcode. Default is 1.
+ -e eofcode : if forstdin has already
+read data, and encounters EOF, exit eofcode. Default is 0.
Other options are used to control
the substitution mechanism for every x. Of course, you can't
split x. The default delimiter for forstdin is a
--
cgit v1.2.3