[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Clarification - Space removal in AE takes place before brace expansion
From: |
Florian Mayer |
Subject: |
Clarification - Space removal in AE takes place before brace expansion |
Date: |
Mon, 01 May 2017 15:49:39 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 |
From my previous mail:
$ echo $(({1..10}’+’ +0)) # with a space between the first + and the
second one
I'm sorry, I assumed that $(()) and (( )) so the exact same thing so I only
included the $(()) version instead of what I tested on my machine.
Apparently both versions do not behave the same.
$ eval echo \$\(\( {1..10}'+' +0\)\)
Works. Adds up to 55, ok.
$ echo $(( {1..10}'+' +0))
Does not work, because:
bash: {1..10}'+' +0: syntax error: operand expected (error token is
"{1..10}'+' +0")
So it seems as though bash does not do brace expansion here.
However,
$ (({1..10}'+' +0))
Gives me "bash: ((: 1+ +0 2+ +0 3+ +0 4+ +0 5+ +0 6+ +0 7+ +0 8+ +0 9+
+0 10+ +0: syntax"
which is the same thing I'd get, when I whould've done {1..10}'+ +0'. Thus
in this same arithmetic expansion context bash _does_ indeed do brace
expansion. But it does
it after it deleted all whitespace inside the (( )) pair.
Why is that?
- Clarification - Space removal in AE takes place before brace expansion,
Florian Mayer <=
Re: Clarification - Space removal in AE takes place before brace expansion, Chet Ramey, 2017/05/01