bug-bash
[Top][All Lists]
Advanced

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

Re: Clarification - Space removal in AE takes place before brace expansi


From: Florian Mayer
Subject: Re: Clarification - Space removal in AE takes place before brace expansion
Date: Mon, 01 May 2017 17:21:03 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

imadev:~$ {1..10}'+ 0'
+ '1+ 0' '2+ 0' '3+ 0' '4+ 0' '5+ 0' '6+ 0' '7+ 0' '8+ 0' '9+ 0' '10+ 0'
bash: 1+ 0: command not found

It most certainly does not evaluate to 55.
Oh, it would've with the expansion put into arithmetic context.

Why can't we just write a loop?
Oh, WE could. But where would be the fun?

Gods save me from friggin' LOBBYISTS.

I feel like LOBBYISTS are taking my freedom to
do stupid things with bash!!1!

expression, and then evaluating that script, leads to one of the problems
I mentioned earlier.
Maybe you might've missed the point, but all bash does is
makro expansion which IS code generation.

the "uses too much memory" problem.  The results of a brace expansion
are actually generated as words stored in memory.  It's not efficient.
It's not elegant.  It's ridiculous and stupid.

Bash itself IS RIDICULOUSLY HUGE and SLOW not just brace expansion.
The whole binary takes up almost 1 mb which is gigantic,
everything is a string and the only
consistency is that it IS INCONSISTENT.

But, I love it dearly

On 05/01/2017 04:54 PM, Greg Wooledge wrote:
On Mon, May 01, 2017 at 04:37:10PM +0200, Florian Mayer wrote:
$ "{1..10}'+' 0"
actually is seen as
$ "{1..10}'+ 0'" # postabmle = '+<space>0'
Then, it expands that to
'1+ 0 2+ 0 3+ 0 4+ 0 5+ 0 6+ 0 7+ 0 8+ 0 9+ 0 10+ 0'
and evaluates it arithmetically resulting in 55.
No, and no.  I think you actually meant to write that without the outer
double quotes.

imadev:~$ set -x
imadev:~$ {1..10}'+ 0'
+ '1+ 0' '2+ 0' '3+ 0' '4+ 0' '5+ 0' '6+ 0' '7+ 0' '8+ 0' '9+ 0' '10+ 0'
bash: 1+ 0: command not found

It most certainly does not evaluate to 55.

With the outer double quotes, you simply get:

imadev:~$ "{1..10}'+ 0'"
+ '{1..10}'\''+ 0'\'''
bash: {1..10}'+ 0': command not found

But doesn't this case show that bash choses the preamble and postable
for the brace expansion wrongly?
No, it shows that you are wishing for a world that does not exist.
Your understanding of what bash does is not yet complete.

Gods save me from friggin' LOBBYISTS.

why can't we just brace expand everything in between (( ))
as if we'h read it verbatimly from the commandline?
Why can't we just write a loop?

In any case where this brace expansion insanity would actually *work*
(result in the correct answer, without breaking the script, or your
system's security, or consuming outrageous amounts of memory), you
could simply write out the literal expression longhand, or simply write
out the *answer*.

You want to print "55"?  echo 55

In any case where the expression is too long to write out longhand,
writing a generator to produce a script that contains the longhand
expression, and then evaluating that script, leads to one of the problems
I mentioned earlier.  Even if you are the Brace Whisperer and you somehow
manage to dodge EVERY security issue involved with eval, you still have
the "uses too much memory" problem.  The results of a brace expansion
are actually generated as words stored in memory.  It's not efficient.
It's not elegant.  It's ridiculous and stupid.




reply via email to

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