Jobs segment no longer works with bash < 5
scop opened this issue · comments
#250 breaks jobs segment with bash < 5. From #249:
In this test case with bash 4.4, 4576
is the one we're interested in:
28448 pts/34 Ss 0:35 | \_ bash
4576 pts/34 S+ 0:34 | \_ bash -i
5138 pts/34 Rl 0:00 | \_ emacs
5193 pts/34 S+ 0:00 | \_ bash -i
5194 pts/34 Sl+ 0:00 | \_ powerline-go -modules [...]
5201 pts/34 R+ 0:00 | \_ ps fax
With bash 5.0.0, 31110
is the one in this case:
28448 pts/34 Ss 0:00 | \_ bash
31110 pts/34 S+ 0:02 | \_ bash -i
4042 pts/34 Sl 0:01 | \_ emacs
4245 pts/34 Sl+ 0:00 | \_ powerline-go -modules [...]
4252 pts/34 R+ 0:00 | \_ ps fax
Modded powerline-go to do and output ps fax
. emacs
is just a canary job there.
So, I suppose we could look into the process group id instead of the parent, maybe that'd work everywhere (well no idea about Windows), with all shells? Confirmed that just changing both -oppid=
s to -opgid=
in the original code makes it work with all bash versions here, didn't try any other shells but I guess they wouldn't be broken as long as the pgid functionality is there in the first place.
Originally posted by @scop in #249 (comment)
From #249 (comment)
Aside, as noted in #250, there are ps incompatibilities to deal with, and the current codepath for bash is broken at least with busybox 1.27.2 ps. Working with something like https://github.com/mitchellh/go-ps/blob/ddafa7589c607e0e81a7436520ccdbac913665a2/process_unix.go#L14 instead should elide those issues. Don't know about Windows.
I've found a way to solve this, but it'd require computing the number in the shell script surrounding the prompt, and passing it to the prompt.
Before I do that, I'd like to hear opinions on that, though. Would that be a trade-off you'd be okay with (changing the .zshrc/.bashrc instead of just upgrading the prompt itself)?
I think that's fine, thanks