aboutsummaryrefslogtreecommitdiff
path: root/coreutils/ls.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-06-07 11:34:06 +0100
committerRon Yorston <rmy@pobox.com>2021-06-07 11:34:06 +0100
commitabe872e2a0342357a5608342cb2892e94027b3e7 (patch)
tree297cdccf332fbb5e4eb31b1eac643180059f9b5f /coreutils/ls.c
parent1f33f42d7bcb019b268d938df643a7a785dc19ab (diff)
parent4d983dcddeee94892d3072e84c7c9a01d4696055 (diff)
downloadbusybox-w32-abe872e2a0342357a5608342cb2892e94027b3e7.tar.gz
busybox-w32-abe872e2a0342357a5608342cb2892e94027b3e7.tar.bz2
busybox-w32-abe872e2a0342357a5608342cb2892e94027b3e7.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'coreutils/ls.c')
-rw-r--r--coreutils/ls.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 67f6c8c56..0330f62df 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -109,11 +109,11 @@
109//usage:#define ls_full_usage "\n\n" 109//usage:#define ls_full_usage "\n\n"
110//usage: "List directory contents\n" 110//usage: "List directory contents\n"
111//usage: "\n -1 One column output" 111//usage: "\n -1 One column output"
112//usage: "\n -a Include entries which start with ." 112//usage: "\n -a Include names starting with ."
113//usage: "\n -A Like -a, but exclude . and .." 113//usage: "\n -A Like -a, but exclude . and .."
114////usage: "\n -C List by columns" - don't show, this is a default anyway 114////usage: "\n -C List by columns" - don't show, this is a default anyway
115//usage: "\n -x List by lines" 115//usage: "\n -x List by lines"
116//usage: "\n -d List directory entries instead of contents" 116//usage: "\n -d List directory names, not contents"
117//usage: IF_FEATURE_LS_FOLLOWLINKS( 117//usage: IF_FEATURE_LS_FOLLOWLINKS(
118//usage: "\n -L Follow symlinks" 118//usage: "\n -L Follow symlinks"
119//usage: "\n -H Follow symlinks on command line" 119//usage: "\n -H Follow symlinks on command line"
@@ -122,10 +122,10 @@
122//usage: "\n -R Recurse" 122//usage: "\n -R Recurse"
123//usage: ) 123//usage: )
124//usage: IF_FEATURE_LS_FILETYPES( 124//usage: IF_FEATURE_LS_FILETYPES(
125//usage: "\n -p Append / to dir entries" 125//usage: "\n -p Append / to directory names"
126//usage: "\n -F Append indicator (one of */=@|) to entries" 126//usage: "\n -F Append indicator (one of */=@|) to names"
127//usage: ) 127//usage: )
128//usage: "\n -l Long listing format" 128//usage: "\n -l Long format"
129//usage: "\n -i List inode numbers" 129//usage: "\n -i List inode numbers"
130//usage: "\n -n List numeric UIDs and GIDs instead of names" 130//usage: "\n -n List numeric UIDs and GIDs instead of names"
131//usage: "\n -s List allocated blocks" 131//usage: "\n -s List allocated blocks"
@@ -134,7 +134,7 @@
134//usage: "\n -lu List atime" 134//usage: "\n -lu List atime"
135//usage: ) 135//usage: )
136//usage: IF_FEATURE_LS_TIMESTAMPS(IF_LONG_OPTS( 136//usage: IF_FEATURE_LS_TIMESTAMPS(IF_LONG_OPTS(
137//usage: "\n --full-time List full date and time" 137//usage: "\n --full-time List full date/time"
138//usage: )) 138//usage: ))
139//usage: IF_FEATURE_HUMAN_READABLE( 139//usage: IF_FEATURE_HUMAN_READABLE(
140//usage: "\n -h Human readable sizes (1K 243M 2G)" 140//usage: "\n -h Human readable sizes (1K 243M 2G)"
@@ -160,7 +160,7 @@
160//usage: "\n -w N Format N columns wide" 160//usage: "\n -w N Format N columns wide"
161//usage: ) 161//usage: )
162//usage: IF_FEATURE_LS_COLOR( 162//usage: IF_FEATURE_LS_COLOR(
163//usage: "\n --color[={always,never,auto}] Control coloring" 163//usage: "\n --color[={always,never,auto}]"
164//usage: ) 164//usage: )
165 165
166#include "libbb.h" 166#include "libbb.h"
@@ -187,7 +187,7 @@
187 187
188 188
189enum { 189enum {
190TERMINAL_WIDTH = 80, /* use 79 if terminal has linefold bug */ 190TERMINAL_WIDTH = 80, /* use 79 if terminal has linefold bug */
191 191
192SPLIT_FILE = 0, 192SPLIT_FILE = 0,
193SPLIT_DIR = 1, 193SPLIT_DIR = 1,
@@ -298,7 +298,7 @@ struct dnode {
298// but there are invisible fields as well 298// but there are invisible fields as well
299// (such as nanosecond-resolution timespamps) 299// (such as nanosecond-resolution timespamps)
300// and padding, which we also don't want to store. 300// and padding, which we also don't want to store.
301// We also can pre-parse dev_t dn_rdev (in glibc, it's huge). 301// We also pre-parse dev_t dn_rdev (in glibc, it's huge).
302// On 32-bit uclibc: dnode size went from 112 to 84 bytes. 302// On 32-bit uclibc: dnode size went from 112 to 84 bytes.
303// 303//
304 /* Same names as in struct stat, but with dn_ instead of st_ pfx: */ 304 /* Same names as in struct stat, but with dn_ instead of st_ pfx: */
@@ -1182,11 +1182,15 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
1182 1182
1183#if ENABLE_FEATURE_LS_COLOR 1183#if ENABLE_FEATURE_LS_COLOR
1184 /* set G_show_color = 1/0 */ 1184 /* set G_show_color = 1/0 */
1185 if (ENABLE_FEATURE_LS_COLOR_IS_DEFAULT && isatty(STDOUT_FILENO)) { 1185 if (ENABLE_FEATURE_LS_COLOR_IS_DEFAULT && !is_TERM_dumb()) {
1186 char *p = getenv("LS_COLORS"); 1186 char *p = getenv("LS_COLORS");
1187 /* LS_COLORS is unset, or (not empty && not "none") ? */ 1187 /* LS_COLORS is unset, or (not empty && not "none") ? */
1188 if (!p || (p[0] && strcmp(p, "none") != 0)) 1188 if (!p || (p[0] && strcmp(p, "none") != 0)) {
1189 G_show_color = 1; 1189 if (isatty(STDOUT_FILENO)) {
1190 /* check isatty() last because it's expensive (syscall) */
1191 G_show_color = 1;
1192 }
1193 }
1190 } 1194 }
1191 if (opt & OPT_color) { 1195 if (opt & OPT_color) {
1192 if (color_opt[0] == 'n') 1196 if (color_opt[0] == 'n')
@@ -1195,7 +1199,7 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
1195 case 3: 1199 case 3:
1196 case 4: 1200 case 4:
1197 case 5: 1201 case 5:
1198 if (isatty(STDOUT_FILENO)) { 1202 if (!is_TERM_dumb() && isatty(STDOUT_FILENO)) {
1199 case 0: 1203 case 0:
1200 case 1: 1204 case 1:
1201 case 2: 1205 case 2: