diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-12-19 16:29:08 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-12-19 16:29:08 +0100 |
commit | 407ab2a4349de67c0a3203cdcb544a3360506291 (patch) | |
tree | 96b91dd68ae20ecd1b003eadc70325f043a2695f | |
parent | 2f7d9e8903029b1b5e51a15f9cb0dcb6ca17c3ac (diff) | |
download | busybox-w32-407ab2a4349de67c0a3203cdcb544a3360506291.tar.gz busybox-w32-407ab2a4349de67c0a3203cdcb544a3360506291.tar.bz2 busybox-w32-407ab2a4349de67c0a3203cdcb544a3360506291.zip |
ls: tweak -e handling; better comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/ls.c | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index 7bc7b28c8..eadd6cee7 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -184,15 +184,20 @@ SPLIT_FILE = 0, | |||
184 | SPLIT_SUBDIR = 2, | 184 | SPLIT_SUBDIR = 2, |
185 | }; | 185 | }; |
186 | 186 | ||
187 | /* "[-]Cadil1", POSIX mandated options, busybox always supports */ | 187 | /* -Cadil1 Std options, busybox always supports */ |
188 | /* "[-]gnsx", POSIX non-mandated options, busybox always supports */ | 188 | /* -gnsxA Std options, busybox always supports */ |
189 | /* "[-]Q" GNU option? busybox always supports */ | 189 | /* -Q GNU option? busybox always supports */ |
190 | /* "[-]Ak" GNU options, busybox always supports */ | 190 | /* -k SELinux option, busybox always supports (ignores if !SELinux) */ |
191 | /* "[-]FLRctur", POSIX mandated options, busybox optionally supports */ | 191 | /* Std has -k which means "show sizes in kbytes" */ |
192 | /* "[-]p", POSIX non-mandated options, busybox optionally supports */ | 192 | /* -FLRctur Std options, busybox optionally supports */ |
193 | /* "[-]SXvThw", GNU options, busybox optionally supports */ | 193 | /* -p Std option, busybox optionally supports */ |
194 | /* "[-]K", SELinux mandated options, busybox optionally supports */ | 194 | /* Not fully compatible - we show not only '/' but other chars too */ |
195 | /* "[-]e", I think we made this one up */ | 195 | /* -SXvhTw GNU options, busybox optionally supports */ |
196 | /* -T TABWIDTH is ignored (we don't use tabs on output) */ | ||
197 | /* -K SELinux mandated options, busybox optionally supports */ | ||
198 | /* -e I think we made this one up (looks similar to GNU --full-time) */ | ||
199 | /* Std opts we do not support: */ | ||
200 | /* -H Follow the links on command line only */ | ||
196 | static const char ls_options[] ALIGN1 = | 201 | static const char ls_options[] ALIGN1 = |
197 | "Cadil1gnsxQAk" /* 13 opts, total 13 */ | 202 | "Cadil1gnsxQAk" /* 13 opts, total 13 */ |
198 | IF_FEATURE_LS_TIMESTAMPS("cetu") /* 4, 17 */ | 203 | IF_FEATURE_LS_TIMESTAMPS("cetu") /* 4, 17 */ |
@@ -229,7 +234,7 @@ enum { | |||
229 | + 2 * ENABLE_SELINUX | 234 | + 2 * ENABLE_SELINUX |
230 | + 2 * ENABLE_FEATURE_AUTOWIDTH, | 235 | + 2 * ENABLE_FEATURE_AUTOWIDTH, |
231 | OPT_F = (1 << OPTBIT_F) * ENABLE_FEATURE_LS_FILETYPES, | 236 | OPT_F = (1 << OPTBIT_F) * ENABLE_FEATURE_LS_FILETYPES, |
232 | OPT_color = 1 << OPTBIT_color, | 237 | OPT_color = (1 << OPTBIT_color), |
233 | }; | 238 | }; |
234 | 239 | ||
235 | /* TODO: simple toggles may be stored as OPT_xxx bits instead */ | 240 | /* TODO: simple toggles may be stored as OPT_xxx bits instead */ |
@@ -248,10 +253,10 @@ static const unsigned opt_flags[] = { | |||
248 | DISP_HIDDEN, /* A */ | 253 | DISP_HIDDEN, /* A */ |
249 | ENABLE_SELINUX * LIST_CONTEXT, /* k (ignored if !SELINUX) */ | 254 | ENABLE_SELINUX * LIST_CONTEXT, /* k (ignored if !SELINUX) */ |
250 | #if ENABLE_FEATURE_LS_TIMESTAMPS | 255 | #if ENABLE_FEATURE_LS_TIMESTAMPS |
251 | TIME_CHANGE | (ENABLE_FEATURE_LS_SORTFILES * SORT_CTIME), /* c */ | 256 | TIME_CHANGE | (ENABLE_FEATURE_LS_SORTFILES * SORT_CTIME), /* c */ |
252 | LIST_FULLTIME, /* e */ | 257 | LIST_FULLTIME, /* e */ |
253 | ENABLE_FEATURE_LS_SORTFILES * SORT_MTIME, /* t */ | 258 | ENABLE_FEATURE_LS_SORTFILES * SORT_MTIME, /* t */ |
254 | TIME_ACCESS | (ENABLE_FEATURE_LS_SORTFILES * SORT_ATIME), /* u */ | 259 | TIME_ACCESS | (ENABLE_FEATURE_LS_SORTFILES * SORT_ATIME), /* u */ |
255 | #endif | 260 | #endif |
256 | #if ENABLE_FEATURE_LS_SORTFILES | 261 | #if ENABLE_FEATURE_LS_SORTFILES |
257 | SORT_SIZE, /* S */ | 262 | SORT_SIZE, /* S */ |
@@ -274,8 +279,6 @@ static const unsigned opt_flags[] = { | |||
274 | #endif | 279 | #endif |
275 | #if ENABLE_SELINUX | 280 | #if ENABLE_SELINUX |
276 | LIST_MODEBITS|LIST_NLINKS|LIST_CONTEXT|LIST_SIZE|LIST_DATE_TIME, /* K */ | 281 | LIST_MODEBITS|LIST_NLINKS|LIST_CONTEXT|LIST_SIZE|LIST_DATE_TIME, /* K */ |
277 | #endif | ||
278 | #if ENABLE_SELINUX | ||
279 | LIST_MODEBITS|LIST_ID_NAME|LIST_CONTEXT, /* Z */ | 282 | LIST_MODEBITS|LIST_ID_NAME|LIST_CONTEXT, /* Z */ |
280 | #endif | 283 | #endif |
281 | (1U<<31) | 284 | (1U<<31) |
@@ -1041,18 +1044,20 @@ int ls_main(int argc UNUSED_PARAM, char **argv) | |||
1041 | /* process options */ | 1044 | /* process options */ |
1042 | IF_FEATURE_LS_COLOR(applet_long_options = ls_longopts;) | 1045 | IF_FEATURE_LS_COLOR(applet_long_options = ls_longopts;) |
1043 | opt_complementary = | 1046 | opt_complementary = |
1047 | /* -e implies -l */ | ||
1048 | "el" | ||
1044 | /* http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls.html: | 1049 | /* http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls.html: |
1045 | * in some pairs of opts, only last one takes effect: | 1050 | * in some pairs of opts, only last one takes effect: |
1046 | */ | 1051 | */ |
1047 | IF_FEATURE_LS_TIMESTAMPS(IF_FEATURE_LS_SORTFILES("t-S:S-t")) /* time/size */ | 1052 | IF_FEATURE_LS_TIMESTAMPS(IF_FEATURE_LS_SORTFILES(":t-S:S-t")) /* time/size */ |
1048 | // ":H-L:L-H:" - we don't have -H | 1053 | // ":H-L:L-H:" - we don't have -H |
1049 | // ":m-l:l-m:" - we don't have -m | 1054 | // ":m-l:l-m:" - we don't have -m |
1050 | ":C-xl:x-Cl:l-xC" /* bycols/bylines/long */ | 1055 | ":C-xl:x-Cl:l-xC" /* bycols/bylines/long */ |
1051 | ":C-1:1-C" /* bycols/oneline */ | 1056 | ":C-1:1-C" /* bycols/oneline */ |
1052 | ":x-1:1-x" /* bylines/oneline (not in SuS, but in GNU coreutils 8.4) */ | 1057 | ":x-1:1-x" /* bylines/oneline (not in SuS, but in GNU coreutils 8.4) */ |
1053 | ":c-u:u-c" /* mtime/atime */ | 1058 | ":c-u:u-c" /* mtime/atime */ |
1054 | /* -T NUM, -w NUM: */ | 1059 | /* -w NUM: */ |
1055 | IF_FEATURE_AUTOWIDTH(":T+:w+"); | 1060 | IF_FEATURE_AUTOWIDTH(":w+"); |
1056 | opt = getopt32(argv, ls_options | 1061 | opt = getopt32(argv, ls_options |
1057 | IF_FEATURE_AUTOWIDTH(, NULL, &terminal_width) | 1062 | IF_FEATURE_AUTOWIDTH(, NULL, &terminal_width) |
1058 | IF_FEATURE_LS_COLOR(, &color_opt) | 1063 | IF_FEATURE_LS_COLOR(, &color_opt) |
@@ -1109,7 +1114,7 @@ int ls_main(int argc UNUSED_PARAM, char **argv) | |||
1109 | all_fmt = (all_fmt & ~SORT_MASK) | SORT_ATIME; | 1114 | all_fmt = (all_fmt & ~SORT_MASK) | SORT_ATIME; |
1110 | } | 1115 | } |
1111 | if ((all_fmt & STYLE_MASK) != STYLE_LONG) /* only for long list */ | 1116 | if ((all_fmt & STYLE_MASK) != STYLE_LONG) /* only for long list */ |
1112 | all_fmt &= ~(LIST_ID_NUMERIC|LIST_FULLTIME|LIST_ID_NAME|LIST_ID_NUMERIC); | 1117 | all_fmt &= ~(LIST_ID_NUMERIC|LIST_ID_NAME|LIST_FULLTIME); |
1113 | if (ENABLE_FEATURE_LS_USERNAME) | 1118 | if (ENABLE_FEATURE_LS_USERNAME) |
1114 | if ((all_fmt & STYLE_MASK) == STYLE_LONG && (all_fmt & LIST_ID_NUMERIC)) | 1119 | if ((all_fmt & STYLE_MASK) == STYLE_LONG && (all_fmt & LIST_ID_NUMERIC)) |
1115 | all_fmt &= ~LIST_ID_NAME; /* don't list names if numeric uid */ | 1120 | all_fmt &= ~LIST_ID_NAME; /* don't list names if numeric uid */ |