[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: read and env variables + POSIX => SEGFAULT
From: |
Chet Ramey |
Subject: |
Re: read and env variables + POSIX => SEGFAULT |
Date: |
Mon, 12 Oct 2015 17:05:27 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 10/10/15 11:01 PM, Linda Walsh wrote:
>> a= read a <<< x;echo $?
> 0
>> declare -p a
> declare -- a="x"
> # the manpage claims "one line is read from [the input], and the result
> # is split by words and assigns 1st word to 1st var and so forth, but
> # apparently the reading of 1 line is optional -- though this is consistent
> # with the fact that read can be told to read some number of characters
> and # return when the limit is reached. So technically, read doesn't
> "read one line",
> # but read whatever is on 'input' up to 1 line. (DOC clarification?)
This is terribly wrong.
The command in question is `a= read a <<< x'.
The here-string construct takes the following word and, like a here
document, makes it the standard input to the command. The standard
input is then a file consisting of a single line: x\n.
It's basically shorthand for
read a <<EOF
x
EOF
So, `read' reads the single line from its standard input and assigns it
to the variable `a'.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
- read and env variables, isabella parakiss, 2015/10/10
- Re: read and env variables + POSIX => SEGFAULT, Linda Walsh, 2015/10/10
- Re: read and env variables + POSIX => SEGFAULT, Geir Hauge, 2015/10/11
- Re: read and env variables + POSIX => SEGFAULT,
Chet Ramey <=
- Message not available
- Re: read and env variables + POSIX => SEGFAULT, Linda Walsh, 2015/10/15
- Re: read and env variables + POSIX => SEGFAULT, Greg Wooledge, 2015/10/13
- Re: read and env variables + POSIX => SEGFAULT, Chet Ramey, 2015/10/15
- my confusion on various I/O redirections syntaxes and indirect methods, Linda Walsh, 2015/10/13
- Re: my confusion on various I/O redirections syntaxes and indirect methods, Greg Wooledge, 2015/10/13
Re: read and env variables, Chet Ramey, 2015/10/11