Skip to content

ugrep immediately breaks pipe with process substitution where grep, and ripgrep succeed #503

@tsujp

Description

@tsujp

I am using process substitution here as I later want to kill the subprocess when the first match is found, but this occurs long before that kind of complexity is reached, what follows is a minimal reproduction.

With ripgrep

$ # ripgrep 14.1.1
$ rg foo <(sleep 1; echo 'foo'; sleep 1; echo 'foo'; sleep 1; echo 'done'; exit 10); echo $?
1:foo
2:foo
0

With grep

$ # grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
$ grep foo <(sleep 1; echo 'foo'; sleep 1; echo 'foo'; sleep 1; echo 'done'; exit 10); echo $?
foo
foo
0

With ugrep

$ # ugrep 7.5.0 aarch64-apple-darwin23.6.0; -P:pcre2jit; -z:zlib,bzip2,lzma,lz4,zstd,7z,tar/pax/cpio/zip
$ ugrep foo <(sleep 1; echo 'foo'; sleep 1; echo 'foo'; sleep 1; echo 'done'; exit 10); echo $?
1

ugrep appears to immediately close the pipe and abort.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions