Date: Sat, 29 Jul 2000 15:04:45 -0400 (EDT) From: mike ryan <msr+fbsd@elision.org> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/20291: [PATCH] ls refuses to output color to anything that's not a tty Message-ID: <20000729190445.A300A1931B@vapre.elision.org>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000729190445.A300A1931B>
