diff options
author | Laurent Bercot <ska-dietlibc@skarnet.org> | 2017-05-26 16:50:53 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-05-26 16:50:53 +0200 |
commit | 2599937c4e5012d8e410d58574d22dec92e6eaa5 (patch) | |
tree | 045f52dfe01397291a8e21de49c0fca08e7beb99 /coreutils/ls.c | |
parent | 13d72c3fd979a047179b1342dcae026379af0617 (diff) | |
download | busybox-w32-2599937c4e5012d8e410d58574d22dec92e6eaa5.tar.gz busybox-w32-2599937c4e5012d8e410d58574d22dec92e6eaa5.tar.bz2 busybox-w32-2599937c4e5012d8e410d58574d22dec92e6eaa5.zip |
ls: fix support for long options when FEATURE_LS_COLOR is deselected
Declaration of ls_longopts and initialization of applet_long_options
were incorrectly guarded with ENABLE_FEATURE_LS_COLOR; that yielded a
"ls: NO_OPT: \xff" error message when long options were selected and
color support was not. This patch ensures long options are
initialized separately from color support.
Signed-off-by: Laurent Bercot <ska-dietlibc@skarnet.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/ls.c')
-rw-r--r-- | coreutils/ls.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index 6e0a52d75..6780057da 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -1067,17 +1067,19 @@ int ls_main(int argc UNUSED_PARAM, char **argv) | |||
1067 | * 'auto', 'tty', 'if-tty' | 1067 | * 'auto', 'tty', 'if-tty' |
1068 | * (and substrings: "--color=alwa" work too) | 1068 | * (and substrings: "--color=alwa" work too) |
1069 | */ | 1069 | */ |
1070 | static const char ls_longopts[] ALIGN1 = | ||
1071 | "full-time\0" No_argument "\xff" | ||
1072 | "group-directories-first\0" No_argument "\xfe" | ||
1073 | "color\0" Optional_argument "\xfd" | ||
1074 | ; | ||
1075 | static const char color_str[] ALIGN1 = | 1070 | static const char color_str[] ALIGN1 = |
1076 | "always\0""yes\0""force\0" | 1071 | "always\0""yes\0""force\0" |
1077 | "auto\0""tty\0""if-tty\0"; | 1072 | "auto\0""tty\0""if-tty\0"; |
1078 | /* need to initialize since --color has _an optional_ argument */ | 1073 | /* need to initialize since --color has _an optional_ argument */ |
1079 | const char *color_opt = color_str; /* "always" */ | 1074 | const char *color_opt = color_str; /* "always" */ |
1080 | #endif | 1075 | #endif |
1076 | #if ENABLE_LONG_OPTS | ||
1077 | static const char ls_longopts[] ALIGN1 = | ||
1078 | "full-time\0" No_argument "\xff" | ||
1079 | "group-directories-first\0" No_argument "\xfe" | ||
1080 | "color\0" Optional_argument "\xfd" | ||
1081 | ; | ||
1082 | #endif | ||
1081 | 1083 | ||
1082 | INIT_G(); | 1084 | INIT_G(); |
1083 | 1085 | ||
@@ -1091,7 +1093,7 @@ int ls_main(int argc UNUSED_PARAM, char **argv) | |||
1091 | #endif | 1093 | #endif |
1092 | 1094 | ||
1093 | /* process options */ | 1095 | /* process options */ |
1094 | IF_FEATURE_LS_COLOR(applet_long_options = ls_longopts;) | 1096 | IF_LONG_OPTS(applet_long_options = ls_longopts;) |
1095 | opt_complementary = | 1097 | opt_complementary = |
1096 | /* -n and -g imply -l */ | 1098 | /* -n and -g imply -l */ |
1097 | "nl:gl" | 1099 | "nl:gl" |