From owner-freebsd-bugs@FreeBSD.ORG Fri Mar 3 17:40:05 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1C6B116A420 for ; Fri, 3 Mar 2006 17:40:05 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 719A343D49 for ; Fri, 3 Mar 2006 17:40:04 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k23He4qJ050349 for ; Fri, 3 Mar 2006 17:40:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k23He49c050348; Fri, 3 Mar 2006 17:40:04 GMT (envelope-from gnats) Resent-Date: Fri, 3 Mar 2006 17:40:04 GMT Resent-Message-Id: <200603031740.k23He49c050348@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, James Bailie Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0219916A428 for ; Fri, 3 Mar 2006 17:37:56 +0000 (GMT) (envelope-from jimmy@jamesbailie.com) Received: from smtp103.rog.mail.re2.yahoo.com (smtp103.rog.mail.re2.yahoo.com [206.190.36.81]) by mx1.FreeBSD.org (Postfix) with SMTP id 869F243D45 for ; Fri, 3 Mar 2006 17:37:55 +0000 (GMT) (envelope-from jimmy@jamesbailie.com) Received: (qmail 79580 invoked from network); 3 Mar 2006 17:37:54 -0000 Received: from unknown (HELO ?HOSTNAME?) (jazzturk@rogers.com@70.29.126.205 with login) by smtp103.rog.mail.re2.yahoo.com with SMTP; 3 Mar 2006 17:37:54 -0000 Received: by _HOSTNAME_ (sSMTP sendmail emulation); Fri, 3 Mar 2006 12:37:54 -0500 Message-Id: <20060303173755.869F243D45@mx1.FreeBSD.org> Date: Fri, 3 Mar 2006 12:37:54 -0500 From: James Bailie To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/94052: [PATCH]: Adds option to script(1) to suppress carriage-returns in log file. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: James Bailie List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Mar 2006 17:40:05 -0000 >Number: 94052 >Category: bin >Synopsis: [PATCH]: Adds option to script(1) to suppress carriage-returns in log file. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Mar 03 17:40:03 GMT 2006 >Closed-Date: >Last-Modified: >Originator: James Bailie >Release: all >Organization: >Environment: System: FreeBSD localhost 5.4-RELEASE-p8 FreeBSD 5.4-RELEASE-p8 #10: Tue Nov 22 11:55:20 EST 2005 jbailie@localhost:/usr/src/sys/i386/compile/LOCAL i386 >Description: >How-To-Repeat: >Fix: --- diff.txt begins here --- diff -ruN /usr/src/usr.bin/script/script.1 script/script.1 --- /usr/src/usr.bin/script/script.1 Fri Jul 2 20:24:43 2004 +++ script/script.1 Fri Mar 3 12:14:48 2006 @@ -80,6 +80,9 @@ Log keys sent to program as well as output. .It Fl q Run in quiet mode, omit the start and stop status messages. +.It Fl c +Collape carriage-return/newline sequences into single newlines when writing +data to log file. .It Fl t Ar time Specify time interval between flushing script output file. A value of 0 diff -ruN /usr/src/usr.bin/script/script.c script/script.c --- /usr/src/usr.bin/script/script.c Sun Feb 15 12:30:13 2004 +++ script/script.c Fri Mar 3 12:18:58 2006 @@ -81,19 +81,20 @@ int main(int argc, char *argv[]) { - int cc; + int cc, ccount; struct termios rtt, stt; struct winsize win; - int aflg, kflg, ch, n; + int aflg, kflg, cflg, ch, n; struct timeval tv, *tvp; time_t tvec, start; + char *ptr; char obuf[BUFSIZ]; char ibuf[BUFSIZ]; fd_set rfd; int flushtime = 30; - aflg = kflg = 0; - while ((ch = getopt(argc, argv, "aqkt:")) != -1) + aflg = kflg = cflg = 0; + while ((ch = getopt(argc, argv, "aqkct:")) != -1) switch(ch) { case 'a': aflg = 1; @@ -104,6 +105,9 @@ case 'k': kflg = 1; break; + case 'c': + cflg = 1; + break; case 't': flushtime = atoi(optarg); if (flushtime < 0) @@ -195,6 +199,17 @@ if (cc <= 0) break; (void)write(STDOUT_FILENO, obuf, cc); + + /* + * Suppress carriage-returns if cflg set. + */ + + if ( cflg ) { + for ( ptr = strnstr( obuf, "\r\n", cc ); ptr != NULL; + ptr = strnstr( ptr, "\r\n", ccount )) + bcopy( ptr + 1, ptr, ccount = --cc - ( ptr - obuf )); + } + (void)fwrite(obuf, 1, cc, fscript); } tvec = time(0); --- diff.txt ends here --- >Release-Note: >Audit-Trail: >Unformatted: