bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Builtin 'read' data not saved


From: Davide Brini
Subject: Re: Builtin 'read' data not saved
Date: Thu, 2 Jan 2014 23:30:35 +0100

On Thu, 2 Jan 2014 11:35:11 -0800, "P Fudd" <address@hidden> wrote:

> Here's some more oddities:
> 
> =====failing.sh:
> #!/bin/bash
> R="1|2"
> IFS='|' read -r A B <<< $R
> echo A=$A, B=$B
> ====
> Expected: "A=1, B=2"
> Actual: "A=1 2, B="
> 
> 
> ====fail2.sh:
> #!/bin/bash
> R="1|2"
> while IFS='|' read -r A B; do
> echo 1:A=$A, B=$B
> done <<< $R
> echo 2:A=$A, B=$B
> ====
> Expected:
>   1:A=1, B=2
>   2:A=1, B=2
> Actual:
>   1:A=1, B=2
>   2:A=, B=
> 
> 
> GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)
> bash-4.2-2ubuntu2.1.deb

This is a FAQ, see http://mywiki.wooledge.org/BashFAQ/024 for a full
discussion.

-- 
D.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]