Crunching
@@ -53,6 +57,8 @@ three consecutive spaces, or a space and 4 tab characters, with a
single space. This is called crunching, and it is done
by giving the -C switch to the substitution command. The
remaining delimiter will always be the first in the sequence.
+Chomping is off by default, or if you give the -c
+switch.
@@ -66,8 +72,10 @@ remaining delimiter will always be the first in the sequence.
Sometimes you don't want the last delimiter in a value.
Chomping deletes the last character of a value if it is a
-delimiter. It can be requested by giving the -n switch to the
-substitution command. Note that chomping always happens after
+delimiter. It is requested by giving the -n switch to the
+substitution command. You can turn it off by giving the -N
+switch. It is off by default unless mentioned in the documentation
+page of specific binaries. Note that chomping always happens after
crunching, which means you can use crunching+chomping to ignore, for
instance, a set of trailing spaces.
@@ -112,11 +120,11 @@ several advantages over the shell's:
+
+
+ Other options are similar (in name and functionality) to the switches
+passed to control a substitution mechanism,
+on purpose; however, forbacktickx does not call the substitution
+mechanism and has its own semantics for those options.
+
+
+
+ - -N : store the whole line in variable,
+including the terminating newline (or other delimiter).
+ - -n : chomp a terminating delimiter from the line from
+stdin before storing it into variable. This is the default.
+ - -C : crunch. If there is an empty line (i.e. that
+only contains a delimiter), do not call loop. If this option is
+given, and chomping is active, and the last line of stdin
+is not terminated by a delimiter, then this last line will not be processed.
+ - -c : do not crunch, call loop even if
+the line is empty. This is the default.
+ - -0 : accept null characters on its stdin,
+using them as delimiters. If this option and a -d option are
+used simultaneously, the rightmost one wins.
+ - -d delim : use the characters in string
+delim as delimiters for a line. Default is "\n", meaning
+the input is only split on newlines.
Notes
diff --git a/doc/forstdin.html b/doc/forstdin.html
index 44939fe..74644b4 100644
--- a/doc/forstdin.html
+++ b/doc/forstdin.html
@@ -30,7 +30,7 @@ run another program.
- forstdin [ -p | -o okcodes | -x breakcodes ] [ -E firsteofcode ] [ -e eofcode ] [ -n ] [ -C | -c ] [ -0 | -d delim ] variable loop...
+ forstdin [ -p | -o okcodes | -x breakcodes ] [ -N | -n ] [ -C | -c ] [ -0 | -d delim ] variable loop...
@@ -50,9 +50,6 @@ and 1 if it hasn't read anything.
instance to finish before spawning the next one. forstdin will
still wait for all instances of loop to terminate before
exiting, though.
- - -0 : accept null characters on its stdin,
-using them as delimiters. If this option and a -d option are
-used simultaneously, the rightmost one wins.
- -o okcodes : okcodes must
be a comma-separated list of exit codes. If the -p flag
hasn't been given and loop exits with one of the codes in
@@ -64,15 +61,33 @@ 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 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
-newline; you need a -d option to split x around
-other values.
+
+
+
+ Other options are similar (in name and functionality) to the switches
+passed to control a substitution mechanism,
+on purpose; however, forstdin does not call the substitution
+mechanism and has its own semantics for those options.
+
+
+
+ - -N : store the whole line in variable,
+including the terminating newline (or other delimiter).
+ - -n : chomp a terminating delimiter from the line from
+stdin before storing it into variable. This is the default.
+ - -C : crunch. If there is an empty line (i.e. that
+only contains a delimiter), do not call loop. If this option is
+given, and chomping is active, and the last line of stdin
+is not terminated by a delimiter, then this last line will not be processed.
+ - -c : do not crunch, call loop even if
+the line is empty. This is the default.
+ - -0 : accept null characters on its stdin,
+using them as delimiters. If this option and a -d option are
+used simultaneously, the rightmost one wins.
+ - -d delim : use the characters in string
+delim as delimiters for a line. Default is "\n", meaning
+the input is only split on newlines.
+ -
Notes
diff --git a/doc/importas.html b/doc/importas.html
index 4ac4a98..ac95e87 100644
--- a/doc/importas.html
+++ b/doc/importas.html
@@ -26,7 +26,7 @@ environment variable, then executes another program.
Interface
- importas [ -i | -D default ] [ -u ] [ -s ] [ -C | -c ] [ -n ] [ -d delim ] variable envvar prog...
+ importas [ -i | -D default ] [ -u ] [ -s ] [ -C | -c ] [ -N | -n ] [ -d delim ] variable envvar prog...
diff --git a/doc/multidefine.html b/doc/multidefine.html
index f3909a2..69ad388 100644
--- a/doc/multidefine.html
+++ b/doc/multidefine.html
@@ -30,7 +30,7 @@ then executes another program.
- multidefine [ -0 ] [ -r ] [ -C | -c ] [ -n ] [ -d delim ] value { variables... } prog...
+ multidefine [ -0 ] [ -r ] [ -C | -c ] [ -N | -n ] [ -d delim ] value { variables... } prog...
@@ -64,6 +64,8 @@ If there are more words in the split value than there are
variables in the block, the last variable will be replaced with all
the remaining words (and will be split). Without this option, the last variable
is replaced with a single word, and the excess words are lost.
+ - Other options are used to control the
+substitution mechanism. Note that the value is always split.