Date: Fri, 1 Feb 2013 19:04:11 GMT From: Gerald Pfeifer <gerald@pfeifer.com> To: FreeBSD-gnats-submit@freebsd.org Subject: ports/175768: ports-mgmt/pkg sends terminal control codes (and duplicate output) even when not running in one Message-ID: <201302011904.r11J4Bff023552@ref10-i386.freebsd.org> Resent-Message-ID: <201302011910.r11JA0g8067731@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 175768 >Category: ports >Synopsis: ports-mgmt/pkg sends terminal control codes (and duplicate output) even when not running in one >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Feb 01 19:10:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Gerald Pfeifer >Release: >Organization: >Environment: >Description: Doing my ports tests via scripts and partly using nohup, I found duplicate output in my logs and escape sequences. So, really two bugs: - status messages appear twice - one of the two copies has an escape sequence and beep embedded >How-To-Repeat: 1. nohup make deinstall or 1. nohup pkg delete ... 2. vi nohup.out >Fix: commit f196ea741f28a7e8919b29b69c7fc815ee882018 Author: Gerald Pfeifer <gerald@pfeifer.com> Date: Fri Feb 1 17:31:17 2013 +0000 Only (try to) set the terminal title if we are actually connected to a terminal. diff --git a/pkg/event.c b/pkg/event.c index 97d6662..f85efd2 100644 --- a/pkg/event.c +++ b/pkg/event.c @@ -96,8 +96,9 @@ event_callback(void *data, struct pkg_event *ev) printf("[%d/%d] ", nbdone, nbactions); printf("Installing %s-%s...", name, version); /* print to the terminal title*/ - printf("%c]0;[%d/%d] Installing %s-%s%c", '\033', nbdone, nbactions, name, version, '\007'); - + if (isatty(fileno(stdout))) + printf("%c]0;[%d/%d] Installing %s-%s%c", '\033', + nbdone, nbactions, name, version, '\007'); break; case PKG_EVENT_INSTALL_FINISHED: if (quiet) @@ -129,8 +130,9 @@ event_callback(void *data, struct pkg_event *ev) if (nbactions > 0) printf("[%d/%d] ", nbdone, nbactions); printf("Deleting %s-%s...", name, version); - printf("%c]0;[%d/%d] Deleting %s-%s%c", '\033', nbdone, - nbactions, name, version, '\007'); + if (isatty(fileno(stdout))) + printf("%c]0;[%d/%d] Deleting %s-%s%c", '\033', nbdone, + nbactions, name, version, '\007'); break; case PKG_EVENT_DEINSTALL_FINISHED: if (quiet) @@ -149,22 +151,25 @@ event_callback(void *data, struct pkg_event *ev) case 1: printf("Downgrading %s from %s to %s...", name, version, newversion); - printf("%c]0;[%d/%d] Downgrading %s from %s to %s%c", - '\033', nbdone, nbactions, name, version, - newversion, '\007'); + if (isatty(fileno(stdout))) + printf("%c]0;[%d/%d] Downgrading %s from %s to %s%c", + '\033', nbdone, nbactions, name, version, + newversion, '\007'); break; case 0: printf("Reinstalling %s-%s", - name, version); - printf("%c]0;[%d/%d] Reinstalling %s-%s%c", '\033', - nbdone, nbactions, name, version, '\007'); + name, version); + if (isatty(fileno(stdout))) + printf("%c]0;[%d/%d] Reinstalling %s-%s%c", '\033', + nbdone, nbactions, name, version, '\007'); break; case -1: printf("Upgrading %s from %s to %s...", name, version, newversion); - printf("%c]0;[%d/%d] Upgrading %s from %s to %s%c", - '\033', nbdone, nbactions, name, version, - newversion, '\007'); + if (isatty(fileno(stdout))) + printf("%c]0;[%d/%d] Upgrading %s from %s to %s%c", + '\033', nbdone, nbactions, name, version, + newversion, '\007'); break; } break; >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201302011904.r11J4Bff023552>