coreutils
[Top][All Lists]
Advanced

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

Re: bug#22045: expr substr returns with an error code 1 when the substri


From: Pádraig Brady
Subject: Re: bug#22045: expr substr returns with an error code 1 when the substring starts with 0
Date: Sun, 29 Nov 2015 05:16:09 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 28/11/15 23:34, Pádraig Brady wrote:
> tag 22045 notabug
> close 22045
> stop
> 
> On 28/11/15 20:47, Matthias Klose wrote:
>> found with coreutils-8.23, expr substr returns with an error code when the 
>> substring consists of only '0' characters, and the match is started at 
>> position 1.
>>
>> $ expr substr 00001234 3 4; echo $?
>> 0012
>> 0
>> $ expr substr 1234 1 2; echo $?
>> 12
>> 0
>>
>> $ expr substr 00001234 1 2; echo $?
>> 00
>> 1
>> $ expr substr 00001234 1 4; echo $?
>> 0000
>> 1
>> $ expr substr 00001234 1 5; echo $?
>> 00001
>> 0
> 
> This is a common gotcha. POSIX states that:
> exit status of 1 is used if "the expression evaluates to null or zero".
> 
> I must collate some gotchas like this.

Initial list started at:
http://www.pixelbeat.org/docs/coreutils-gotchas.html




reply via email to

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