Skip to content

jq -e always returns 0 for empty input #1142

@rfletcher

Description

@rfletcher

jq -e always exits with status 0 when passed empty input. For example:

$ echo | jq --exit-status 'false'; echo $?
0

Consider a use case like this one:

call-some-json-api |
jq --exit-status '.field == "some-value"' &&
take-action

If the API call fails and output is only written to stderr, take-action will still run as though the call succeeded, and "some-value" had been set.

This may be related to issue #667, but that one has been fixed on master, and this bug is still present.

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