[Top][All Lists]

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

[suggestion] Brace expansion configurability

From: omasmotorrad
Subject: [suggestion] Brace expansion configurability
Date: Sun, 30 Apr 2017 17:23:08 +0200

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 
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:

reply via email to

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