bug-bash
[Top][All Lists]
Advanced

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

Re: built-in printf returns success when integer is out of range


From: Chet Ramey
Subject: Re: built-in printf returns success when integer is out of range
Date: Thu, 27 Jul 2023 11:32:01 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 7/26/23 4:18 PM, thomas@habets.se wrote:

Bash Version: 5.2
Patch Level: 15
Release Status: release

Description:
         printf '%d\n' 111111111111111111111111111 && echo success
         prints "success"
         /usr/bin/printf does not, but instead returns EXIT_FAILURE (1).

The bash printf builtin doesn't consider this an error -- it prints a
warning -- because strtoimax completely converts the argument (*ep == 0)
even as it changes errno to ERANGE. That dates back to bash-2.05b.

I can make ERANGE overflow a conversion error as well; that seems
consistent with POSIX and what other shells do.

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