Skip to content

Browser shell grep -q returns success for non-matching input #708

Description

@brandonpayton

In the browser shell demo, GNU grep currently returns status 0 for matching and non-matching input when run from the PTY shell. This made the merge-gate NetHack check report KANDELO_NETHACK_BAD even though /tmp/kandelo-nethack.out did not contain Cannot open record file.

Focused browser repro from the shell demo:

printf 'abc\\n' >/tmp/g\ngrep -q zzz /tmp/g; echo "GREP_FILE_NO:$?"\ngrep -q abc /tmp/g; echo "GREP_FILE_YES:$?"\nprintf 'abc\\n' | grep -q zzz; echo "GREP_STDIN_NO:$?"\nprintf 'abc\\n' | grep -q abc; echo "GREP_STDIN_YES:$?"\n```\n\nObserved in Chromium against `apps/browser-demos` on this branch after rebuilding `shell.vfs.zst`:\n\n```text\nGREP_FILE_NO:0\nGREP_FILE_YES:0\nGREP_STDIN_NO:0\nGREP_STDIN_YES:0\n```\n\nExpected: no-match cases should exit 1. The existing package tests cover grep stdin through `runCentralizedProgram`, but the browser PTY path needs coverage for grep exit status and file operands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions