Skip to content

Detect $status being carried over from last command #6815

Description

@soumya92

fish, version 3.1.0

I did not expect this:

soumya@machine /h/soumya> false
soumya@machine /h/soumya [1]> set foo bar
soumya@machine /h/soumya [1]> sleep 2 &
Job 1, 'sleep 2 &' has ended
soumya@machine /h/soumya [1]>

soumya@machine /h/soumya> true
soumya@machine /h/soumya> set foo bar
soumya@machine /h/soumya> sleep 2 &
Job 1, 'sleep 2 &' has ended
soumya@machine /h/soumya> 

I understand why this is happening, since both set and & do not modify the status. And that behaviour is great for scripts.

But it was still surprising to me that the [1] carried over in the prompt. Would it be possible for $status to be cleared somehow in preexec, so that it's only set to a non-zero value if it was explicitly caused by the last command? Or introduce a variable that could indicate that the previous command had no status?

(I tried set status 0 in --on-event fish_preexec, but as expected, that did not work)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions