[BusyBox] patch: allow ls coloring to be disabled
Paul Fox
pgf at brightstareng.com
Wed Nov 10 12:44:14 UTC 2004
> > + lscolor = getenv("BB_LSCOLOR");
> > + if (!lscolor)
> > + show_color = 1; /* backwards compatible default */
>
> Hmm. If BB_LSCOLOR undeclared you switch on show color without check isatty.
> Its not backwards compatible.
argh. thanks. i guess we're all starting to figure out how i
feel about color in an ls output, eh? :-)
obvious correction below:
--- busybox-1.00.orig/coreutils/ls.c 2004-09-23 22:04:13.000000000 -0400
+++ busybox-1.00/coreutils/ls.c 2004-11-09 12:09:37.000000000 -0500
@@ -984,8 +984,20 @@
#endif
#ifdef CONFIG_FEATURE_LS_COLOR
- if (isatty(STDOUT_FILENO))
- show_color = 1;
+ {
+ char *lscolor;
+ lscolor = getenv("BB_LSCOLOR");
+ if (!lscolor)
+ show_color = isatty(STDOUT_FILENO); /* default */
+ else if (*lscolor == 'n') /* never */
+ show_color = 0;
+ else if (*lscolor == 'a') {
+ if (*(lscolor+1) == 'l') /* always */
+ show_color = 1;
+ else if (*(lscolor+1) == 'u') /* auto */
+ show_color = isatty(STDOUT_FILENO);
+ }
+ }
#endif
/* process options */
=---------------------
paul fox, pgf at brightstareng.com
More information about the busybox
mailing list