On 5/1/17 10:00 AM, Greg Wooledge wrote: > On Mon, May 01, 2017 at 03:49:39PM +0200, Florian Mayer wrote: >> 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? > > Ooh, you fixed your quotes. Yay. > > To answer your question, I would guess it has something to do with what > the bash parser considers a "word". Brace expansion occurs when an > unquoted part of a word contains a legitimate brace-expansion substring > such as {a,b} or {a..c}. > > In your case, it looks like the parser considers the entire inside of the > arithmetic command to be one "word", with a brace expansion inside it. > So, the brace expansion is performed on that word, and you get > > ((1+ +0 2+ +0 3+ +0 ...)) > > which you can confirm by re-running your command with set -x.
This is true. The contents of an arithmetic command are considered one word, and are documented to be equivalent to `let' executed with the contents as a single string. So `(( ... ))' and `let "..."' are exactly equivalent. The whitespace discrepancy might be caused by the fact that brace expansion generates multiple words, which have to be rejoined into a single string. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/