aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/ls.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 80ef92079..1f7d7f7bf 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -1145,11 +1145,15 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
1145 1145
1146#if ENABLE_FEATURE_LS_COLOR 1146#if ENABLE_FEATURE_LS_COLOR
1147 /* set G_show_color = 1/0 */ 1147 /* set G_show_color = 1/0 */
1148 if (ENABLE_FEATURE_LS_COLOR_IS_DEFAULT && isatty(STDOUT_FILENO)) { 1148 if (ENABLE_FEATURE_LS_COLOR_IS_DEFAULT && !is_TERM_dumb()) {
1149 char *p = getenv("LS_COLORS"); 1149 char *p = getenv("LS_COLORS");
1150 /* LS_COLORS is unset, or (not empty && not "none") ? */ 1150 /* LS_COLORS is unset, or (not empty && not "none") ? */
1151 if (!p || (p[0] && strcmp(p, "none") != 0)) 1151 if (!p || (p[0] && strcmp(p, "none") != 0)) {
1152 G_show_color = 1; 1152 if (isatty(STDOUT_FILENO)) {
1153 /* check isatty() last because it's expensive (syscall) */
1154 G_show_color = 1;
1155 }
1156 }
1153 } 1157 }
1154 if (opt & OPT_color) { 1158 if (opt & OPT_color) {
1155 if (color_opt[0] == 'n') 1159 if (color_opt[0] == 'n')
@@ -1158,7 +1162,7 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
1158 case 3: 1162 case 3:
1159 case 4: 1163 case 4:
1160 case 5: 1164 case 5:
1161 if (isatty(STDOUT_FILENO)) { 1165 if (!is_TERM_dumb() && isatty(STDOUT_FILENO)) {
1162 case 0: 1166 case 0:
1163 case 1: 1167 case 1:
1164 case 2: 1168 case 2: