From owner-freebsd-bugs Sat Jul 29 12:10: 7 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 0248137B779 for ; Sat, 29 Jul 2000 12:10:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id MAA44438; Sat, 29 Jul 2000 12:10:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from vapre.elision.org (r83aap006377.sbo-smr.ma.cable.rcn.com [146.115.122.245]) by hub.freebsd.org (Postfix) with ESMTP id 495B237B779 for ; Sat, 29 Jul 2000 12:02:44 -0700 (PDT) (envelope-from mryan01@vapre.elision.org) Received: by vapre.elision.org (Postfix, from userid 1000) id A300A1931B; Sat, 29 Jul 2000 15:04:45 -0400 (EDT) Message-Id: <20000729190445.A300A1931B@vapre.elision.org> Date: Sat, 29 Jul 2000 15:04:45 -0400 (EDT) From: mike ryan To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/20291: [PATCH] ls refuses to output color to anything that's not a tty Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 20291 >Category: bin >Synopsis: [PATCH] ls refuses to output color to anything that's not a tty >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: Sat Jul 29 12:10:02 PDT 2000 >Closed-Date: >Last-Modified: >Originator: mike ryan >Release: FreeBSD 4.1-STABLE i386 >Organization: >Environment: freebsd 4.1-stable >Description: /bin/ls refuses to generate ansi color codes unless stdout is a terminal. this prevents "ls -G | less -R" from working, for instance. >How-To-Repeat: /bin/ls -G | /usr/bin/less -R >Fix: the patch below forces color output if two -G flags are used. this allows "ls -GG | less -R" while preserving existing -G behavior. Index: bin/ls/ls.c =================================================================== RCS file: /home/ncvs/src/bin/ls/ls.c,v retrieving revision 1.32.2.3 diff -c -r1.32.2.3 ls.c *** bin/ls/ls.c 2000/07/12 06:19:14 1.32.2.3 --- bin/ls/ls.c 2000/07/29 18:19:19 *************** *** 120,125 **** --- 120,126 ---- char *ansi_fgcol; /* ANSI sequence to set foreground colour */ char *ansi_coloff; /* ANSI sequence to reset colours */ #endif + int num_opt_G = 0; /* number of -G flags */ int rval; *************** *** 202,208 **** fts_options |= FTS_COMFOLLOW; break; case 'G': ! if (isatty(STDOUT_FILENO)) #ifdef COLORLS if (tgetent(termcapbuf, getenv("TERM")) == 1) { ansi_fgcol = tgetstr("AF", &bp); --- 203,209 ---- fts_options |= FTS_COMFOLLOW; break; case 'G': ! if (num_opt_G++ || isatty(STDOUT_FILENO)) #ifdef COLORLS if (tgetent(termcapbuf, getenv("TERM")) == 1) { ansi_fgcol = tgetstr("AF", &bp); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message