bug-bash
[Top][All Lists]
Advanced

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

Re: [here string] uncompatible change on here string function


From: Greg Wooledge
Subject: Re: [here string] uncompatible change on here string function
Date: Wed, 22 Nov 2017 08:04:56 -0500
User-agent: NeoMutt/20170113 (1.7.2)

On Wed, Nov 22, 2017 at 11:22:47AM +0800, 尹剑虹 wrote:
>       The command line to the right of  "<<<"  is no longer cut by IFS
> 
>       [yjh@bash4.4 ~]$ var=$(echo -e "foo\t\tbar")
>       [yjh@bash4.4 ~]$ read a <<<$var; echo "$a"
>       foo             bar
> 
>       [yjh@bash4.2 ~]$ var=$(echo -e "foo\t\tbar")
>       [yjh@bash4.2 ~]$ read a <<<$str; echo "$a"
>       foo bar

Quoting failure.

wooledg:~$ bash-4.2
wooledg:~$ var=$'foo\t\tbar'
wooledg:~$ cat <<< "$var"
foo             bar
wooledg:~$ read -r a <<< "$var"; declare -p a
declare -- a="foo               bar"

When in doubt, always double-quote your variable expansions.  (Except
on the right-hand side of =~ inside a [[ command.)

<http://mywiki.wooledge.org/Quotes> goes into more detail.



reply via email to

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