Re: printf does not return error on readonly assignment
From:
Chet Ramey
Subject:
Re: printf does not return error on readonly assignment
Date:
Thu, 6 Jul 2017 10:32:45 -0400
User-agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.2.1
On 7/6/17 12:41 AM, Arnaud Gaillard wrote:
> Bash Version: 4.4
> Patch Level: 12
> Release Status: release
>
> Description:
>
> According to the help page of the `printf` builtin, it
> should not return success when an error has occurred during the
> assignment:
>
>> Exit Status:
>> Returns success unless an invalid option is given or a write or assignment
>> error occurs.
>
> Assigning a value to a `readonly` variable returns an error code:
>
>> bash$ readonly a=2
>> bash$ a=3
>> -bash: a: readonly variable
>> bash$ echo $?
>> 1
>
> However, assigning the value to a `readonly` variable via `printf -v`
> returns success:
Thanks for the report. This is a reasonable improvement to make.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/