[pacman-dev] [PATCH 3/3] provide context messages when stdout is redirected

Simon Gomizelj simongmzlj at gmail.com
Thu Feb 28 14:54:30 EST 2013


Since the prompt to proceed with the installation/download will now get
printed to the underlying tty directly, they won't show up when stdout
has been redirected.

Add some messages to provide context instead.

Signed-off-by: Simon Gomizelj <simongmzlj at gmail.com>
---
 src/pacman/sync.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index b1cc3fe..99a7397 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -804,9 +804,24 @@ int sync_prepare_execute(void)
 	}
 	if(!confirm) {
 		retval = 1;
+		if(!isatty(fileno(stdout))) {
+			if(config->op_s_downloadonly) {
+				printf(_("Download aborted.\n"));
+			} else {
+				printf(_("Installation aborted.\n"));
+			}
+		}
 		goto cleanup;
 	}
 
+	if(!isatty(fileno(stdout))) {
+		if(config->op_s_downloadonly) {
+			printf(_("Proceeding with download...\n"));
+		} else {
+			printf(_("Proceeding with installation...\n"));
+		}
+	}
+
 	if(alpm_trans_commit(config->handle, &data) == -1) {
 		alpm_errno_t err = alpm_errno(config->handle);
 		pm_printf(ALPM_LOG_ERROR, _("failed to commit transaction (%s)\n"),
-- 
1.8.1.4



More information about the pacman-dev mailing list