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
Add a $status_generation variable to track when $status was changed #6820
Add a $status_generation variable to track when $status was changed #6820
Conversation
fish_postexec
Apologies for delay in review. I recognize the need here and I want to find a solution, but I think this particular approach is too complex. Let's continue discussion in #6815. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your continued effort, this looks great!
I have some minor comments. If you don't want to bother I can do the cleanups.
Any idea why switching int -> maybe_t in the builtins is causing I don't know enough C++ to figure this one out. I can confirm that without that change clang configure and make works fine, (even though -latomic is not present in the build flags), and after that change it fails (-latomic is still not present in the build flags). |
The build failure is mysterious.. I could reproduce it at first and now it builds fine with clang. |
Added a change to cmake that I think will fix the build issue on clang |
Alright, I think this is basically ready! One more thing: the new parameter to https://github.com/gazorby/fish-abbreviation-tips/blob/b02b13b32db0aedd000e293167cba59e1235ac41/conf.d/abbr_tips.fish I guess we can just not care about this, since it's not that many. However, thinking about this, couldn the interface be better if we expose the holdover status not as hook parameter, but instead - true to its name - in the "status" builtin. I think something like (Also if you end up making more changes you can run a |
Yeah, good point regarding compat of this solution. I don't know if status is-holdover is simple to implement and explain, since it needs to use some reference point for checking the holdover state. I've implemented @ridiculousfish's suggestion on the linked issue (to use a "generation" variable), which does have the downside of documentation as you mention, but probably works better and was much easier to implement. PTAL, thanks. |
…active command that produces a status. This can be used to determine whether the previous command produced a real status, or just carried over the status from the command before it. Backgrounded commands and variable assignments will not increment status_generation, all other commands will.
It's not entirely clear why the existing check does not work, but it seems to pass on clang++ even without -latomic, but causes the fish build to fail later. Confirmed that with this change, g++ does not use -latomic, while clang++ does, and fish builds fine with both.
I tried clang-format, but it made no changes. Is there some configuration I need to import?
|
Oh maybe my clang-format 10 is newer than yours, don't worry about it. |
Yeah, it looks like We could expose a
|
Uses regular text when the status is carried over, e.g. after a background job.
With your suggestion of checking generation in fish_prompt, now they do :) |
I think this is awesome!! I love the subtle tweak to the default prompt. Also really well factored, easily reviewable change set.
Big thanks to @soumya92 for this contribution! |
Thanks! I'm glad I was able to add this feature, since I will use it a lot :) |
Description
Attempt to differentiate between explicitly setting $status and implicitly re-using a previous $status value through a
$status_generation
electric variable. Currently this only affects backgrounded jobs and variable assignments.This variable will be automatically incremented after every interactive command, except
command &
orset foo bar
.This will allow tools like "undistract me" to correctly report the exit status of the last command, by ignoring
$status
infish_postexec
iff the value of$status_generation
is the same in pre and post exec.It could potentially be extended to support something like
return --previous
in fish script, if the feature is useful enough to warrant that complexity.Fixes #6815 #6998
TODOs: