From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH gfs2-utils] mkfs.gfs2: make are you sure EOF happy
Date: Thu, 14 Jan 2021 11:56:34 +0000 [thread overview]
Message-ID: <51fe8a57-60af-e581-3eab-2380bfdbee87@redhat.com> (raw)
In-Reply-To: <20210113173646.43173-1-aahringo@redhat.com>
On 13/01/2021 17:36, Alexander Aring wrote:
> This patch adds a check for getline() error, as the manpage states out
> that -1 is returned in EOF case we answer such case and possible
> other errors with no. If you currently press ctrl-d during this question
> an endless loop of asking this question over and over again will occur.
> However this patch changes to handle errors with no and prints a newline
> so the user have a new clean shell prompt afterwards. If getline reads
> zero characters .e.g '\n', the question is if we are sure is asked again.
>
> Signed-off-by: Alexander Aring <aahringo@redhat.com>
> ---
> gfs2/mkfs/main_mkfs.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Applied, thanks Alex.
Andy
>
> diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
> index 5e34ca1f..e6fc6532 100644
> --- a/gfs2/mkfs/main_mkfs.c
> +++ b/gfs2/mkfs/main_mkfs.c
> @@ -528,9 +528,14 @@ static int are_you_sure(void)
> `locale -k noexpr` */
> printf( _("Are you sure you want to proceed? [y/n] "));
> ret = getline(&line, &len, stdin);
> + if (ret < 0) {
> + printf("\n");
> + free(line);
> + return 0;
> + }
> res = rpmatch(line);
> free(line);
> - if (ret <= 0)
> + if (ret == 0)
> continue;
> if (res == 1) /* Yes */
> return 1;
>
prev parent reply other threads:[~2021-01-14 11:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-13 17:36 [Cluster-devel] [PATCH gfs2-utils] mkfs.gfs2: make are you sure EOF happy Alexander Aring
2021-01-14 11:56 ` Andrew Price [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51fe8a57-60af-e581-3eab-2380bfdbee87@redhat.com \
--to=anprice@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.