[PATCH] ls: fix support for long options when FEATURE_LS_COLOR is deselected
Xabier Oneca -- xOneca
xoneca at gmail.com
Fri May 26 12:15:59 UTC 2017
Hello!
2017-05-26 13:38 GMT+02:00 Laurent Bercot <ska-dietlibc at skarnet.org>:
> 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.
> ---
> coreutils/ls.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/coreutils/ls.c b/coreutils/ls.c
> index 6e0a52d75..50aaf132c 100644
> --- a/coreutils/ls.c
> +++ b/coreutils/ls.c
> @@ -1067,11 +1067,6 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
> * 'auto', 'tty', 'if-tty'
> * (and substrings: "--color=alwa" work too)
> */
> - static const char ls_longopts[] ALIGN1 =
> - "full-time\0" No_argument "\xff"
> - "group-directories-first\0" No_argument "\xfe"
> - "color\0" Optional_argument "\xfd"
> - ;
> static const char color_str[] ALIGN1 =
> "always\0""yes\0""force\0"
> "auto\0""tty\0""if-tty\0";
> @@ -1079,6 +1074,13 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
> const char *color_opt = color_str; /* "always" */
> #endif
>
> +#if ENABLE_LONG_OPTS
> + static const char ls_longopts[] ALIGN1 =
> + "full-time\0" No_argument "\xff"
> + "group-directories-first\0" No_argument "\xfe"
> + "color\0" Optional_argument "\xfd"
Shouldn't "--color" be guarded by IF_FEATURE_LS_COLOR, then?
> + ;
> +#endif
> INIT_G();
>
> init_unicode();
> @@ -1091,7 +1093,7 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
> #endif
>
> /* process options */
> - IF_FEATURE_LS_COLOR(applet_long_options = ls_longopts;)
> + IF_LONG_OPTS(applet_long_options = ls_longopts;)
> opt_complementary =
> /* -n and -g imply -l */
> "nl:gl"
> --
> 2.13.0.90.g1eb437020
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
Cheers,
Xabier Oneca_,,_
More information about the busybox
mailing list