[prev in list] [next in list] [prev in thread] [next in thread]
List: coreutils-bug
Subject: bug#22045: expr substr returns with an error code 1 when the substring starts with 0
From: Assaf Gordon <assafgordon () gmail ! com>
Date: 2015-11-28 23:38:00
Message-ID: 565A3AD8.7020108 () gmail ! com
[Download RAW message or body]
tag 22045 notabug
close 22045
stop
Hello,
On 11/28/2015 03:47 PM, 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 1 4; echo $?
> 0000
> 1
> $ expr substr 00001234 1 5; echo $?
> 00001
> 0
'expr' is unique in its exit-codes: exit codes of 0 or 1 *do not* indicate \
success/error, but whether the result evaluated to null or zero:
From POSIX:
http://pubs.opengroup.org/onlinepubs/009695399/utilities/expr.html#tag_04_50_14
"
The following exit values shall be returned:
0 The expression evaluates to neither null nor zero.
1 The expression evaluates to null or zero.
2 Invalid expression.
> 2 An error occurred.
"
And so, the exit codes you see indeed match the last computer value.
regards,
- assaf
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic