ZSH exit code not passed to the prompt

Open
#3,034 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
zsh
Domain
cli

Research direction

Start by reproducing the issue in Warp with the provided ~/.zshrc functions and compare the behavior with another terminal. The fix is complete when the exit status from forced_fail is preserved for prompt substitution and FAILED appears in the prompt.

Written by the indexing model from the issue text.

Description

area:shell-terminal bug ready-to-implement triaged
Discord username (optional)

No response

Describe the bug

When I try to pass the exit code to my prompt using zsh and $? it always returns 0. Even if I run a function that returns 1. It will still be a 0.

To Reproduce
# in ~/.zshrc

show_fail() {
    if [ $? = 1 ]; then echo "FAILED"; fi;
}

PROMPT='$(show_fail)'

function forced_fail() {
  return 1
}
$ forced_fail
Expected behavior

Expect to see: "FAILED" displayed on the prompt
What I see: Nothing. The command failed (turns red) but does not show "FAILED"

Screenshots

In Terminal

Screen Shot 2023-05-06 at 10 41 22 AM

in Warp

Screen Shot 2023-05-06 at 10 42 11 AM

Operating System

MacOS

Operating System and Version

Monterey 12.6.3

Shell Version

zsh 5.8.1 (x86_64-apple-darwin21.0)

Warp Version

v0.2023.05.02.08.03.stable_00

Additional context

No response

Does this block you from using Warp daily?

No

Is this a Warp specific issue? (i.e. does it happen in Terminal, iTerm, Kitty, etc.)

Yes, this I confirmed this only happens in Warp, not other terminals.

Warp Internal (ignore): linear-label:b8107fdf-ba31-488d-b103-d271c89cac3e

None

Dominant language
Rust
Stars
65.1k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from warpdotdev/warp

All issues in warpdotdev/warp

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.