fix: pipestatus quoting on Zsh/Bash #3088
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Modifies pipestatus parsing for the starship binary and changes the initscripts for bash/zsh to quote pipestatus. This allows starship to start without errors in the case where pipestatus is empty (usually due to interactions with other shell frameworks).
Motivation and Context
The previous implementation of pipestatus assumed that the arguments to pipestatus would be word-split (bash, zsh) or repeated by the shell (fish). Unfortunately, this causes a shell parse error if pipestatus is not set on first invocation (which can apparently happen if other shell frameworks are present).
There are two ways to fix this:
--pipestatus
at all when pipestatus is detected to be empty.--pipestatus
, which allows clap to detect an empty argument, and then change the parsing code in starship to split the arguments ourselves.I have implemented the second here, since the first requires significantly complicating the init scripts for bash/zsh.
Screenshots (if appropriate):
How Has This Been Tested?
I'll mark this as ready once I can confirm that this fixes the linked bug in the provided docker.Confirmed that this does solve the issue mentioned above. There is a separate issue which appears, where on shell startup, the exit status of the previous command is not defined, so starship prints a warning about not being able to parse the exit status. However, it's not as clear to me how to fix that issue, since we do want the warning to appear when a status cannot be parsed.
Checklist: