From owner-freebsd-ports-bugs@FreeBSD.ORG Fri Feb 1 19:10:00 2013 Return-Path: Delivered-To: freebsd-ports-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id CB9743D1 for ; Fri, 1 Feb 2013 19:10:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id AFA789E8 for ; Fri, 1 Feb 2013 19:10:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r11JA05x067732 for ; Fri, 1 Feb 2013 19:10:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r11JA0g8067731; Fri, 1 Feb 2013 19:10:00 GMT (envelope-from gnats) Resent-Date: Fri, 1 Feb 2013 19:10:00 GMT Resent-Message-Id: <201302011910.r11JA0g8067731@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Gerald Pfeifer Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id A3792261 for ; Fri, 1 Feb 2013 19:04:11 +0000 (UTC) (envelope-from gerald@FreeBSD.org) Received: from ref10-i386.freebsd.org (ref10-i386.freebsd.org [IPv6:2001:1900:2254:206c::16:8a]) by mx1.freebsd.org (Postfix) with ESMTP id 862F29A8 for ; Fri, 1 Feb 2013 19:04:11 +0000 (UTC) Received: from ref10-i386.freebsd.org (localhost [127.0.0.1]) by ref10-i386.freebsd.org (8.14.6/8.14.6) with ESMTP id r11J4BQN023553 for ; Fri, 1 Feb 2013 19:04:11 GMT (envelope-from gerald@ref10-i386.freebsd.org) Received: (from gerald@localhost) by ref10-i386.freebsd.org (8.14.6/8.14.6/Submit) id r11J4Bff023552; Fri, 1 Feb 2013 19:04:11 GMT (envelope-from gerald) Message-Id: <201302011904.r11J4Bff023552@ref10-i386.freebsd.org> Date: Fri, 1 Feb 2013 19:04:11 GMT From: Gerald Pfeifer To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.114 Subject: ports/175768: ports-mgmt/pkg sends terminal control codes (and duplicate output) even when not running in one X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Gerald Pfeifer List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2013 19:10:00 -0000 >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 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: