Un-deprecate the -G flag at obrien's request. Colour sequences are still

dependent upon the output being directed to a terminal however.
(Use the CLICOLOR_FORCE variable to force output).
This commit is contained in:
Josef Karthauser 2000-08-13 12:17:03 +00:00
parent 710591b796
commit d4413063b3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=64604
2 changed files with 20 additions and 11 deletions

View File

@ -43,7 +43,7 @@
.Nd list directory contents
.Sh SYNOPSIS
.Nm ls
.Op Fl ABCFHLPRTWabcdfgiklnoqrstu1
.Op Fl ABCFGHLPRTWabcdfgiklnoqrstu1
.Op Ar file ...
.Sh DESCRIPTION
For each operand that names a
@ -91,8 +91,9 @@ a percent sign (%) after each whiteout,
and a vertical bar (|) after each that is a
.Tn FIFO .
.It Fl G
This flag has been deprecated. Please use the
.Ev CLICOLOR environment variable instead.
Enable colorized output. This option is equivalent to defining
.Ev CLICOLOR
in the environment. (See below).
.It Fl H
Symbolic links on the command line are followed. This option is assumed if
none of the
@ -395,10 +396,19 @@ you need to set your
.Ev TERM
variable to
.Dq xterm-color .
Other terminal types may require similar adjustments.
Other terminal types may require similar adjustments. Colorization
is silently disabled if the output isn't directed to a terminal
unless the
.Ev CLICOLOR_FORCE
variable is defined.
.It Ev CLICOLOR_FORCE
Color sequences are normally disabled if the output isn't directed to
a color capable terminal. This can be overridden by setting this flag.
a terminal. This can be overridden by setting this flag.
The
.Ev TERM
variable still needs to reference a color capable terminal however
otherwise it is not possible to determine which color sequences to
use.
.It Ev COLUMNS
If this variable contains a string representing a
decimal integer, it is used as the

View File

@ -202,12 +202,7 @@ main(argc, argv)
fts_options |= FTS_COMFOLLOW;
break;
case 'G':
#ifdef COLORLS
(void)fprintf(stderr, "The -G flag is deprecated, please define CLICOLOR instead.\n");
setenv("CLICOLOR", "", 1);
#else
(void)fprintf(stderr, "Color support not compiled in.\n");
#endif
break;
case 'L':
fts_options &= ~FTS_PHYSICAL;
@ -282,10 +277,10 @@ main(argc, argv)
argc -= optind;
argv += optind;
#ifdef COLORLS
/* Enabling of colours is conditional on the environment. */
if (getenv("CLICOLOR") &&
(isatty(STDOUT_FILENO) || getenv("CLICOLOR_FORCE")))
#ifdef COLORLS
if (tgetent(termcapbuf, getenv("TERM")) == 1) {
ansi_fgcol = tgetstr("AF", &bp);
ansi_bgcol = tgetstr("AB", &bp);
@ -299,7 +294,11 @@ main(argc, argv)
if (ansi_fgcol && ansi_bgcol && ansi_coloff)
f_color = 1;
}
#else
(void)fprintf(stderr, "Color support not compiled in.\n");
#endif /*COLORLS*/
#ifdef COLORLS
if (f_color) {
/*
* We can't put tabs and color sequences together: