Implement new read --null flag

The `--null` flag to `read` makes it split incoming lines on NUL instead
of newlines. This is intended for processing the output of a command
that uses NUL separators (such as `find -print0`).

Fixes #1694.
This commit is contained in:
Kevin Ballard
2014-09-21 19:18:56 -07:00
parent f889ad0fda
commit 8f8c4cdd17
8 changed files with 192 additions and 43 deletions

View File

@@ -33,6 +33,8 @@ The following options are available:
- `-a` or `--array` stores the result as an array.
- `-z` or `--null` reads up to NUL instead of newline. Disables interactive mode.
`read` reads a single line of input from stdin, breaks it into tokens based on the `IFS` shell variable, and then assigns one token to each variable specified in `VARIABLES`. If there are more tokens than variables, the complete remainder is assigned to the last variable. As a special case, if `IFS` is set to the empty string, each character of the input is considered a separate token.
If `-a` or `--array` is provided, only one variable name is allowed and the tokens are stored as an array in this variable.