[suggestion] Brace expansion configurability

2017-04-30 Thread omasmotorrad
Why is it that one cannot change the delimiter for the
words generated during brace expansion?

On stackexchange, there too are questions
regarding this. Personally I’d like to be able to write
$ IFS=„,“ echo a{b,c,d}
rather than
$ echo a{b,c,d} | tr „ „ „,“

In this example both lines are equally long but
considerably slower. At $work I’m forced to use windows.
For that reason, my Linux machine runs inside a VM which apparently makes
context switching much slower compared to my natively running
bash at $home.

Is there a possibility to change the delimiter that brace expansion
uses to separate the generated words?
If not: My suggestion:
1) Brace expansion could always take the first byte of IFS. This would not
break previous behavior, because IFS is already set so that it contains space 
as its first character.
For the case, that this indeed would break things. We could
2) Introduce another bash special Variable. For instance BASH_BDEL or BFS 
(Brace Field Separator)….
The line
$ IFS=„,“ echo a{b,c,d}
would change appropriately

Another advantage will be, that we’d be able to replicate strings very 
efficiently using only
builtin resources. Even the very minimalistic standard library of lua has 
string.rep
lua $ print(string.rep(„foo“, 3)) => foofoofoo
could be translated to
$ BFS=„“ echo {,,}foo

What do you think?

If (1) is possible, what parts of bash would I have to touch to do a quick and 
dirty hack
for the time being?

For reference:
https://unix.stackexchange.com/questions/121653/how-to-output-comma-separated-strings-using-bash-brace-expansion
http://stackoverflow.com/questions/30891856/change-separator-delim-in-bash-brace-expansion


Space removal in AE takes place before brace expansion

2017-04-30 Thread Florian Mayer
I want to add up all numbers from 1 to 10, but when I do 
$ echo $(({1,10}’+’ +0)) # with a space between the first + and the second one
I get an error:
bash: ((: 1+ ,3 10+ ,3: syntax error: operand expected (error token is ",3 10+ 
,3“)

It seems as if brace expansion gets executed first (as expected) but with
all the spaces removed that had existed before inside the (( )) parentheses 
pair.
The line
$ (( {1, 10}'+' ,3)) # (space between 1 and 10)
also gives the same error and thus shows that spaces are removed before
brace expansion takes place. Why is that?

I’d consider this a bug, because brace expansion is expected to execute first
and with regards to semantics, spaces are significant...

$ eval echo \$\(\( {1..10}'+' 0\)\)
does the trick, though…