fish-shell/doc_src/read.txt
Mark Griffiths c070a2aa3e Documentation update
Rework for Doxygen >1.8. Moved large parts of the documentation to a
simplified format, making use of Markdown enhancements and fixing bad
long options.
2014-08-01 03:37:32 +01:00

38 lines
1.8 KiB
Text

\section read read - read line of input into variables
\subsection read-synopsis Synopsis
\fish{syn}
read [OPTIONS] [VARIABLES...]
\endfish
\subsection read-description Description
`read` reads one line from standard
input and stores the result in one or more shell variables.
The following options are available:
- `-c CMD` or `--command=CMD` sets the initial string in the interactive mode command buffer to `CMD`.
- `-g` or `--global` makes the variables global.
- `-l` or `--local` makes the variables local.
- `-m NAME` or `--mode-name=NAME` specifies that the name NAME should be used to save/load the history file. If NAME is fish, the regular fish history will be available.
- `-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 `set_color green; echo read; set_color normal; echo "> "`.
- `-s` or `--shell` enables syntax highlighting, tab completions and command termination suitable for entering shellscript code in the interactive mode.
- `-u` or `--unexport` prevents the variables from being exported to child processes (default behaviour).
- `-U` or `--universal` causes the specified shell variable to be made universal.
- `-x` or `--export` exports the variables to child processes.
`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.
See the documentation for `set` for more details on the scoping rules for
variables.
\subsection read-example Example
The following code stores the value 'hello' in the shell variable
`$foo`.
`echo hello|read foo`