aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-12-19 05:05:34 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-12-19 05:05:34 +0100
commitf313746a6d7b992918386a5e6db1cfc8f4da30fd (patch)
tree4fb89c12567c6faf975ffd2276ffb082ec9dd070
parent1393fc116109ba96034470a926933e1bcd518470 (diff)
downloadbusybox-w32-f313746a6d7b992918386a5e6db1cfc8f4da30fd.tar.gz
busybox-w32-f313746a6d7b992918386a5e6db1cfc8f4da30fd.tar.bz2
busybox-w32-f313746a6d7b992918386a5e6db1cfc8f4da30fd.zip
ls: for some options, only last takes effect. Closes bug 2959
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/ls.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 72f58c253..8d1f91921 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -984,13 +984,23 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
984 984
985 /* process options */ 985 /* process options */
986 IF_FEATURE_LS_COLOR(applet_long_options = ls_longopts;) 986 IF_FEATURE_LS_COLOR(applet_long_options = ls_longopts;)
987#if ENABLE_FEATURE_AUTOWIDTH 987 opt_complementary =
988 opt_complementary = "T+:w+"; /* -T N, -w N */ 988 /* http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls.html:
989 opt = getopt32(argv, ls_options, &tabstops, &terminal_width 989 * in some pairs of opts, only last one takes effect:
990 IF_FEATURE_LS_COLOR(, &color_opt)); 990 */
991#else 991 IF_FEATURE_LS_TIMESTAMPS(IF_FEATURE_LS_SORTFILES("t-S:S-t")) /* time/size */
992 opt = getopt32(argv, ls_options IF_FEATURE_LS_COLOR(, &color_opt)); 992 // ":H-L:L-H:" - we don't have -H
993#endif 993 // ":m-l:l-m:" - we don't have -m
994 ":C-xl:x-Cl:l-xC" /* bycols/bylines/long */
995 ":C-1:1-C" /* bycols/oneline */
996 ":x-1:1-x" /* bylines/oneline (not in SuS, but in GNU coreutils 8.4) */
997 ":c-u:u-c" /* mtime/atime */
998 /* -T NUM, -w NUM: */
999 IF_FEATURE_AUTOWIDTH(":T+:w+");
1000 opt = getopt32(argv, ls_options
1001 IF_FEATURE_AUTOWIDTH(, &tabstops, &terminal_width)
1002 IF_FEATURE_LS_COLOR(, &color_opt)
1003 );
994 for (i = 0; opt_flags[i] != (1U<<31); i++) { 1004 for (i = 0; opt_flags[i] != (1U<<31); i++) {
995 if (opt & (1 << i)) { 1005 if (opt & (1 << i)) {
996 unsigned flags = opt_flags[i]; 1006 unsigned flags = opt_flags[i];
@@ -1054,7 +1064,7 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
1054 if ((all_fmt & STYLE_MASK) == STYLE_LONG && (all_fmt & LIST_ID_NUMERIC)) 1064 if ((all_fmt & STYLE_MASK) == STYLE_LONG && (all_fmt & LIST_ID_NUMERIC))
1055 all_fmt &= ~LIST_ID_NAME; /* don't list names if numeric uid */ 1065 all_fmt &= ~LIST_ID_NAME; /* don't list names if numeric uid */
1056 1066
1057 /* choose a display format */ 1067 /* choose a display format if one was not already specified by an option */
1058 if (!(all_fmt & STYLE_MASK)) 1068 if (!(all_fmt & STYLE_MASK))
1059 all_fmt |= (isatty(STDOUT_FILENO) ? STYLE_COLUMNS : STYLE_SINGLE); 1069 all_fmt |= (isatty(STDOUT_FILENO) ? STYLE_COLUMNS : STYLE_SINGLE);
1060 1070