Skip to content

expr 50 & 40 is behaving differently than GNU #5315

@sylvestre

Description

@sylvestre

Working on the fuzzer:
#4642
with gnu:

$ /usr/bin/expr 223 \& 0
0
$ /usr/bin/expr 223 \& 32
223

With ours:

./target/debug/expr 233 \& 0
0
./target/debug/expr 233 \& 0
0

Docs says:
Return its first argument if neither argument is null or zero, otherwise 0. It does not evaluate its second argument if its first argument is null or zero.

Probably a side effect, in the GNU tests, we can see:


     # In 5.1.3 and earlier, these would report errors.
     ['andand', '0 \& 1 / 0', {OUT => '0'}, {EXIT => 1}],
     ['oror', '1 \| 1 / 0', {OUT => '1'}, {EXIT => 0}],

With our impl:

$ ./target/debug/coreutils expr 0 \& 1 / 0
expr: division by zero

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions