[bsdgrep] outputs color sequences even when stdout is not tty

From: Anonymous <swell.k_at_gmail.com>
Date: Sat, 24 Jul 2010 05:50:25 +0400
I've got a breakage in bin/csh

  $ make depend
  grep '[FV]_' /usr/src/bin/csh/../../contrib/tcsh/ed.defns.c | grep '^#define' >> ed.defns.h
  grep 'ERR_' /usr/src/bin/csh/../../contrib/tcsh/sh.err.c | grep '^#define' >> sh.err.h
  cc -E -O2 -pipe -march=native -I. -I/usr/src/bin/csh -I/usr/src/bin/csh/../../contrib/tcsh -D_PATH_TCSHELL='"/bin/csh"' -DNO_NLS_CATALOGS -ggdb -std=gnu99 -fstack-protector -Wno-pointer-sign /usr/src/bin/csh/../../contrib/tcsh/tc.const.c /usr/src/bin/csh/../../contrib/tcsh/sh.char.h /usr/src/bin/csh/config.h /usr/src/bin/csh/../../contrib/tcsh/config_f.h /usr/src/bin/csh/../../contrib/tcsh/sh.types.h sh.err.h -D_h_tc_const | grep 'Char STR' |  sed -e 's/Char \([a-zA-Z0-9_]*\)\(.*\)/extern Char \1[];/' |  sort >> tc.const.h
  cc -o gethost  -O2 -pipe -march=native -I. -I/usr/src/bin/csh -I/usr/src/bin/csh/../../contrib/tcsh -D_PATH_TCSHELL='"/bin/csh"' -DNO_NLS_CATALOGS -ggdb -std=gnu99 -fstack-protector -Wno-pointer-sign /usr/src/bin/csh/../../contrib/tcsh/gethost.c
  In file included from /usr/src/bin/csh/../../contrib/tcsh/sh.h:488:0,
                   from /usr/src/bin/csh/../../contrib/tcsh/gethost.c:33:
  ./sh.err.h:4:1: error: stray '\33' in program
  ./sh.err.h:4:2: error: expected identifier or '(' before '[' token
  ./sh.err.h:4:5: error: invalid suffix "m" on integer constant
  ./sh.err.h:4:5: error: expected identifier or '(' before numeric constant
  ...

  $ vis $(make -V .OBJDIR)/sh.err.h | head
  /* Do not edit this file, make creates it. */
  #ifndef _h_sh_err
  #define _h_sh_err
  \^[[1;33m\^[[K#define\^[[m\^[[K \^[[1;33m\^[[KERR_\^[[m\^[[KFLAGS       0xf0000000
  \^[[1;33m\^[[K#define\^[[m\^[[K \^[[1;33m\^[[KERR_\^[[m\^[[KNAME        0x10000000
  \^[[1;33m\^[[K#define\^[[m\^[[K \^[[1;33m\^[[KERR_\^[[m\^[[KSILENT      0x20000000
  \^[[1;33m\^[[K#define\^[[m\^[[K \^[[1;33m\^[[KERR_\^[[m\^[[KOLD         0x40000000
  \^[[1;33m\^[[K#define\^[[m\^[[K \^[[1;33m\^[[KERR_\^[[m\^[[KSYNTAX      0

  $ printenv | fgrep -i grep
  GREP_COLOR=1;33
  GREP_OPTIONS=--color --exclude \*.svn\*

I think it should behave like ls(1) and gnu grep(1) and strip color
sequences if stdout is not associated with terminal.
Received on Fri Jul 23 2010 - 23:55:33 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:05 UTC