\section read read - read line of input into variables
\subsection read-synopsis Synopsis
read [OPTIONS] [VARIABLES...]
\subsection read-description Description
The read builtin causes fish to read one line from standard
input and store the result in one or more environment variables.
- -c CMD or --command=CMD specifies that the initial string in the interactive mode command buffer should be CMD.
- -e or --export specifies that the variables will be exported to subshells.
- -g or --global specifies that the variables will be made global.
- -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 specifies that the output of the shell command PROMPT_CMD should be used as the prompt for the interactive mode prompt. The default prompt command is set_color green; echo read; set_color normal; echo "> ".
- -s
or --shell
Use syntax highlighting, tab completions and command termination suitable for entering shellscript code
- -u
or --unexport
causes the specified environment not to be exported to child processes
- -U
or --universal
causes the specified environment variable to be made universal. If this option is supplied, the variable will be shared between all the current users fish instances on the current computer, and will be preserved across restarts of the shell.
- -x
or --export
causes the specified environment variable to be exported to child processes
Read starts by reading a single line of input from stdin, the line is
then tokenized using the IFS environment variable. Each variable
specified in VARIABLES is then assigned one tokenized string
element. If there are more tokens than variables, the complete
remainder is assigned to the last variable.
\subsection read-example Example
echo hello|read foo
Will cause the variable \$foo to be assigned the value hello.