bug-bash
[Top][All Lists]
Advanced

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

Re: AW: Misbehavior with constants and bash script


From: Chet Ramey
Subject: Re: AW: Misbehavior with constants and bash script
Date: Tue, 20 Nov 2018 09:39:43 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.3.1

On 11/20/18 6:38 AM, Alexander Reintzsch wrote:

> and if I add an empty command after the assignment statement it behaves as 
> expected.
> 
> echo "A"
> declare -r vconst="I am fixed."
> echo "B"
> vconst="new value" : # please note the : at the end. (no operation command)
> echo "C" # now printed

I would use `true'. `:' is a special builtin, and a POSIX interpretation
clarified that a non-interactive shell is supposed to exit if a variable
assignment error occurs when the assignment precedes a special builtin.

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



reply via email to

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