From 91cce31a8ecba7f7bf7aa5edfac6d07eb5751030 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 10 Feb 2017 12:54:23 +0100 Subject: sfdisk: --quiet fixes Addresses: https://github.com/karelzak/util-linux/issues/412 Signed-off-by: Karel Zak --- disk-utils/sfdisk.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'disk-utils/sfdisk.c') diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index c6d57eacc..eedaa39d9 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -1683,6 +1683,8 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv) } refresh_prompt_buffer(sf, devname, next_partno, created); + + if (sf->prompt && (sf->interactive || !sf->quiet)) { #ifndef HAVE_LIBREADLINE fputs(sf->prompt, stdout); @@ -1702,7 +1704,8 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv) continue; } else if (rc == 1) { rc = SFDISK_DONE_EOF; - fputs(_("Done.\n"), stdout); + if (!sf->quiet) + fputs(_("Done.\n"), stdout); break; } @@ -1731,7 +1734,7 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv) rc = rc == 0 ? SFDISK_DONE_ASK : SFDISK_DONE_ABORT; break; } else if (!rc) { /* add partition */ - if (!sf->interactive && + if (!sf->interactive && !sf->quiet && (!sf->prompt || startswith(sf->prompt, SFDISK_PROMPT))) { refresh_prompt_buffer(sf, devname, next_partno, created); fputs(sf->prompt, stdout); @@ -1739,8 +1742,7 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv) rc = fdisk_add_partition(sf->cxt, pa, &cur_partno); if (rc) { errno = -rc; - fdisk_warn(sf->cxt, _("Failed to add partition")); - + fdisk_warn(sf->cxt, _("Failed to add #%d partition"), next_partno + 1); } } -- cgit v1.2.3-55-g7522