Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fish prompt: preserve pipestatus #1530

Merged
merged 1 commit into from Jan 30, 2020

Conversation

@krobelus
Copy link
Contributor

krobelus commented Jan 30, 2020

The upcoming release fish 3.1.0 provides a variable $pipestatus, that
exposes the exit code of each process in a pipeline. This $pipestatus
is also used by the new default prompt.

Presently, $status is restored but not $pipestatus, so a prompt displaying
the pipestatus is wrong:

expected:

(env) $ false | true | false
(env) [1|0|1] $

actual:

(env) $ false | true | false
(env) [0|1] $

The wrong $pipestatus is because echo 'exit 1' | source is used
to restore the $status.
This commit solves this problem more elegantly by running the user's
prompt immediately, and printing it later.
Uses the fish builtin "string" command which exists since fish 2.3b1
(released April 19, 2016) so that's unlikely to cause problems.

Thanks for contributing a pull request, see checklist all is good!

  • wrote descriptive pull request text
  • added/updated test(s)
  • updated/extended the documentation
  • added news fragment in docs/changelog folder
The upcoming release fish 3.1.0 provides a variable $pipestatus, that
exposes the exit code of each process in a pipeline. This $pipestatus
is also used by the new default prompt.

Presently, $status is restored but not $pipestatus, so a prompt displaying
the pipestatus is wrong:

expected:

	(env) $ false | true | false
	(env) [1|0|1] $

actual:

	(env) $ false | true | false
	(env) [0|1] $

The wrong $pipestatus is because `echo 'exit 1' | source` is used
to restore the $status.
This commit solves this problem more elegantly by running the user's
prompt immediately, and printing it later.
Uses the fish builtin "string" command which exists since fish 2.3b1
(released April 19, 2016) so that's unlikely to cause problems.
@krobelus krobelus mentioned this pull request Jan 30, 2020
1 of 4 tasks complete
@gaborbernat gaborbernat merged commit 5f802b0 into pypa:rewrite Jan 30, 2020
34 checks passed
34 checks passed
pypa.virtualenv Build #pypa.virtualenv_20200130.03 succeeded
Details
pypa.virtualenv (dev linux) dev linux succeeded
Details
pypa.virtualenv (docs linux) docs linux succeeded
Details
pypa.virtualenv (docs windows) docs windows succeeded
Details
pypa.virtualenv (fix_lint linux) fix_lint linux succeeded
Details
pypa.virtualenv (fix_lint windows) fix_lint windows succeeded
Details
pypa.virtualenv (package_readme linux) package_readme linux succeeded
Details
pypa.virtualenv (package_readme windows) package_readme windows succeeded
Details
pypa.virtualenv (py27 linux) py27 linux succeeded
Details
pypa.virtualenv (py27 macOs) py27 macOs succeeded
Details
pypa.virtualenv (py27 windows) py27 windows succeeded
Details
pypa.virtualenv (py35 linux) py35 linux succeeded
Details
pypa.virtualenv (py35 macOs) py35 macOs succeeded
Details
pypa.virtualenv (py35 vs2017-win2016) py35 vs2017-win2016 succeeded
Details
pypa.virtualenv (py36 linux) py36 linux succeeded
Details
pypa.virtualenv (py36 macOs) py36 macOs succeeded
Details
pypa.virtualenv (py36 vs2017-win2016) py36 vs2017-win2016 succeeded
Details
pypa.virtualenv (py37 linux) py37 linux succeeded
Details
pypa.virtualenv (py37 macOs) py37 macOs succeeded
Details
pypa.virtualenv (py37 vs2017-win2016) py37 vs2017-win2016 succeeded
Details
pypa.virtualenv (py38 linux) py38 linux succeeded
Details
pypa.virtualenv (py38 macOs) py38 macOs succeeded
Details
pypa.virtualenv (py38 vs2017-win2016) py38 vs2017-win2016 succeeded
Details
pypa.virtualenv (pypy linux) pypy linux succeeded
Details
pypa.virtualenv (pypy macOs) pypy macOs succeeded
Details
pypa.virtualenv (pypy windows) pypy windows succeeded
Details
pypa.virtualenv (pypy3 linux) pypy3 linux succeeded
Details
pypa.virtualenv (pypy3 macOs) pypy3 macOs succeeded
Details
pypa.virtualenv (pypy3 windows) pypy3 windows succeeded
Details
pypa.virtualenv (report_coverage) report_coverage succeeded
Details
pypa.virtualenv (upgrade linux) upgrade linux succeeded
Details
pypa.virtualenv (upgrade windows) upgrade windows succeeded
Details
pypa.virtualenv (zipapp linux) zipapp linux succeeded
Details
pypa.virtualenv (zipapp windows) zipapp windows succeeded
Details
@gaborbernat

This comment has been minimized.

Copy link
Contributor

gaborbernat commented Jan 30, 2020

Thanks for the patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.