Skip to main content

Module prompt

Module prompt 

Source
Expand description

The one place proc asks a yes/no question.

Every command that changes processes asks through ask: kill, stop, freeze, thaw, free, unstick, stuck --kill and orphans --kill. (clippy.toml bans dialoguer’s interact methods everywhere else.)

A person who approves something must be able to see it. The list of what would change used to go to stdout while the question went to stderr, so with stdout in a file, or a pipe whose reader had left (proc kill node | head -n1), the question came with no list and y was a blind yes. Now:

  • stdout is a terminal: the list goes to stdout, as it always did.
  • stdout is anything else (a file, a pipe): the list goes to stderr, right above the question, which is on stderr and so is a terminal here (see must_confirm). The person sees what they approve and stdout stays what the command’s output is.
  • the list could not be written where it was meant to go: nothing is asked and nothing is changed. It is exit 4, needs_confirmation, like any other case where nobody can be asked.

The question also restores the terminal when a signal ends proc while it is waiting (see interrupt), and shows the cursor again when it is over however it ended.

Functions§

ask
Show show, the list of processes that action is about to change, and ask question. Ok(true) is a yes and Ok(false) a no.