[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: command substitution bug
From: |
Chet Ramey |
Subject: |
Re: command substitution bug |
Date: |
Sat, 3 Dec 2016 12:27:53 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 |
On 12/2/16 6:23 AM, parasite parasite wrote:
> GNU bash, version 4.3.46(1)-release (x86_64-unknown-linux-gnu)
> GCC: (GNU) 6.1.1
> On archlinux 4.4.27-1-lts
>
> Hello, today i tried something simple but it leads to what seems to be a bug.
>
> $ var="$(for ((i=0;i<$#;i++));do echo line;done)"
> leads to: "unexpected EOF while looking for matching `)'
>
> I think it's because bash interprets "^#" as "#" which means that what
> follow is commented.
Thanks for the report. What happens is that bash skips over the `$' and
assumes that the `#'' starts a word. An easy workaround is to precede the
`$' with a space. I'll fix it in the next devel branch push.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/