Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11639

Re: read and env variables + POSIX => SEGFAULT

Path csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!usenet.stanford.edu!not-for-mail
From Linda Walsh <bash@tlinx.org>
Newsgroups gnu.bash.bug
Subject Re: read and env variables + POSIX => SEGFAULT
Date Mon, 12 Oct 2015 16:39:45 -0700
Lines 69
Approved bug-bash@gnu.org
Message-ID <mailman.188.1444693197.7904.bug-bash@gnu.org> (permalink)
References <CAAZkfoJuwe4o1rPQrfB-vxqeAaBX-=9NPWgv2uiOPdHq7L8g+g@mail.gmail.com> <5619D0F1.6080904@tlinx.org> <561C2097.5080808@case.edu> <561C4456.9020308@tlinx.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1444693197 29720 208.118.235.17 (12 Oct 2015 23:39:57 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash <bug-bash@gnu.org>
Envelope-to bug-bash@gnu.org
User-Agent Thunderbird
In-Reply-To <561C4456.9020308@tlinx.org>
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic]
X-Received-From 173.164.175.65
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.14
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:11639

Show key headers only | View raw



(Cc: Chet Ramey... forgot to send it to list...oop)


Chet Ramey wrote:
> 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'.
----
I wasn't sure if it put the "\n" at the end in a 1-line example.

Does it also use a tmp file and use process-substitution, or is
that only when parens are present?  I.e.

read a < <( echo x)

I'm under the impression, uses a tmp file.

does the read a <<< x
also use a tmp file?

I.e. is
> readarray -t a < <( echo -e 'x\ny\n')
> declare -p a
declare -a a='([0]="x" [1]="y")'

implemented the same way as
> a=(x y)
> b=$(printf "%s\n" ${a[@]})
> readarray -t ar <<< "${b[@]}"
> declare -p a
declare -a a='([0]="x" [1]="y")'



>
>
>
>

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: read and env variables + POSIX => SEGFAULT Linda Walsh <bash@tlinx.org> - 2015-10-12 16:39 -0700

csiph-web