Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Add customizable `vcs` prompt theme (was Re: [RFC][PATCH] `newuser` prompt theme)



On Thu, Jun 10, 2021 at 8:45 PM Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
>
> I was expecting the readonly parameter at the top to print an error.
>
>   % readonly -gHA _prompt_vcs_ps1_default=()
>   % readonly -gHA _prompt_vcs_ps1_default=()
>   zsh: read-only variable: _prompt_vcs_ps1_default

That doesn't actually happen, because prompt_vcs_setup gets redefined
inside the first call to prompt_vcs_setup. $_prompt_vcs_ps1_default
gets set only the first time you call prompt_vcs_setup.


> It's also unclear to me whether this prompt supports clean
> deinitialization and repeated initialization. Doesn't look like it.
> Does it?

You're supposed to use this prompt theme with prompinit's `prompt`
function. If you do so, then deinitialization and repeated
initialization is pretty much clean, as far as I can tell. Is there
anything in particular that I should be checking?


> > > Why is prompt_vcs_precmd checking whether prompt_vcs_fd is a readable
> > > fd? How can it not be?
> >
> > I don't know how or why, but if I don't check for that, then I get
> > this error repeatedly:
> >
> > prompt_vcs_precmd:6: failed to close file descriptor 11: bad file descriptor
>
> Then the check must be masking a bug. This bug can result in the
> closing of another file descriptor that is not owned by prompt_vcs.
>
> I took a quick look and perhaps the bug is due to prompt_vcs_fd-widget
> not unsetting prompt_vcs_fd?

You're right: Unsetting prompt_vcs_fd in prompt_vcs_fd-widget fixes it. Thanks!


> I see that the code is sending SIGKILL now and not waiting for the
> process to terminate. Both of these make me nervous. The code also
> *looks like* it would work without monitor but it wouldn't (it would
> result in unbounded background processes and zombies). What do you
> think about not killing anything and ensuring that at most one
> background process runs at once? This is what I do in my zsh theme and
> it works well.

That sounds great, but I have no idea how to do that. :) Can you give
me some pointers?


> Handling errors from `read` would be nice.

What kind of errors?




Messages sorted by: Reverse Date, Date, Thread, Author