help-bash
[Top][All Lists]
Advanced

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

Re: bash optimization away question


From: Chet Ramey
Subject: Re: bash optimization away question
Date: Sun, 3 Nov 2024 15:03:15 -0500
User-agent: Mozilla Thunderbird

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.


--
``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/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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