Re: [hackers] [sbase][PATCH 1/2] libutil: Implement a simple yes/no prompt

From: Sebastian LaVine <mail_AT_smlavine.com>
Date: Sat, 19 Nov 2022 20:15:47 -0500

On Sat Nov 19, 2022 at 4:42 PM EST, Alan Potteiger wrote:
> `promptyn` fills the requirement for the prompts that need implemented
> in `cp`, `mv`, and `rm` through the `-i` flag.

Technically, I don't think it does. For example, cp(1p)[0] states:

> If the -i option is in effect, the cp utility shall
> write a prompt to the standard error and read a line
> from the standard input. If the response is not
> affirmative, cp shall do nothing more with
> source_file and go on to any remaining files.

This only reads a single character, not a line as the standard states.
If the user responds with 'y\n', then that '\n' is going to be read if
the program takes any more input. I suggest using getline(3) instead.

[0]: https://www.man7.org/linux/man-pages/man1/cp.1p.html
Received on Sun Nov 20 2022 - 02:15:47 CET

This archive was generated by hypermail 2.3.0 : Sun Nov 20 2022 - 02:24:29 CET