help-bash
[Top][All Lists]
Advanced

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

Re: bash optimization away question


From: #!microsuxx
Subject: Re: bash optimization away question
Date: Sun, 3 Nov 2024 22:21:31 +0100

On Sun, Nov 3, 2024, 21:03 Chet Ramey <chet.ramey@case.edu> wrote:

> On 11/2/24 8:29 PM, #!microsuxx wrote:
> > is a
> >
> > var=${var:-blabla}
> >
> > optimized away to no exec at all
> > if var is not empty
> > ?
>
> No. The expansion has to take place, to account for side effects, and the
> attempted assignment has to take place, since that can have side effects
> and transform the value to be assigned as well. It doesn't make sense to
> try and preserve the information about which variable was expanded for
> this corner case.
>

.. so if a var is 10mb big
and id do a couple of plain useless var=$var simply
will it take much cpu , or nearly none ?

-- 
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/
>


reply via email to

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