docs: update language in read documentation

This commit is contained in:
David Adam 2017-08-12 12:20:49 +08:00 committed by Kurtis Rader
parent 263cdc50db
commit 7b7bb5803f

View File

@ -7,7 +7,7 @@ read [OPTIONS] [VARIABLES...]
\subsection read-description Description
`read` reads from standard input and stores the result in one or more shell variables. By default it reads one line terminated by a newline but options are available to read up to a null character and to limit each "line" to a maximum number of characters.
`read` reads from standard input and stores the result in one or more shell variables. By default, one line (terminated by a newline) is read into each variable. Alternatively, a null character or a maximum number of characters can be used to terminate the input. Unlike other shells, there is no default variable (such as `REPLY`) for storing the result.
The following options are available:
@ -19,7 +19,8 @@ The following options are available:
- `-l` or `--local` makes the variables local.
- `-n NCHARS` or `--nchars=NCHARS` causes `read` to return after reading NCHARS characters rather than waiting for a complete line of input (either newline or null terminated).
- `-n NCHARS` or `--nchars=NCHARS` makes `read` return after reading NCHARS characters or the end of
the line, whichever comes first.
- `-p PROMPT_CMD` or `--prompt=PROMPT_CMD` uses the output of the shell command `PROMPT_CMD` as the prompt for the interactive mode. The default prompt command is <code>set_color green; echo read; set_color normal; echo "> "</code>.
@ -37,7 +38,8 @@ The following options are available:
- `-a` or `--array` stores the result as an array in a single variable.
- `-z` or `--null` reads up to NUL instead of newline. Disables interactive mode.
- `-z` or `--null` marks the end of the line with the NUL character, instead of newline. This also
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.
@ -45,9 +47,10 @@ If `-a` or `--array` is provided, only one variable name is allowed and the toke
See the documentation for `set` for more details on the scoping rules for variables.
When read reaches the end-of-file (EOF) instead of the separator, it sets `$status` to 1. If not, it sets it to 0.
When `read` reaches the end-of-file (EOF) instead of the terminator, the exit status is set to 1.
Otherwise, it is set to 0.
Fish has a default limit of 10 MiB on the number of characters each `read` will consume. If you attempt to read more than that `$status` is set to 122 and the variable will be empty. You can modify that limit by setting the `FISH_READ_BYTE_LIMIT` variable at any time including in the environment before fish starts running. If you set it to zero then no limit is imposed. This is a safety mechanism to keep the shell from consuming an unreasonable amount of memory if the input is malformed.
In order to protect the shell from consuming too many system resources, `read` will only consume a maximum of 10 MiB (1048576 bytes); if the terminator is not reached before this limit then VARIABLE is set to empty and the exit status is set to 122. This limit can be altered with the `FISH_READ_BYTE_LIMIT` variable. If set to 0 (zero), the limit is removed.
\subsection read-history Using another read history file