Locale support enabled breaks fractional usage in sleep applet

Denys Vlasenko vda.linux at googlemail.com
Fri Sep 24 08:32:51 UTC 2010


On Thu, Sep 23, 2010 at 5:00 PM, Harald Becker <ralda at gmx.de> wrote:
>  Hi!
>
> If the locale support is enabled in Busybox 1.17.2 it breaks usage of
> fractional in the sleep applet. Without locale support you can specify
> an argument of 0.5s to sleep and it works correct. As soon as locale
> support is enabled the usage message is displayed when any argument with
> a fractional is specified. Locale/libraries are installed correct and
> work in other programs. The LANG/LC_ variables are set correct (I'm
> using en_US.UTF-8 for LANG and de_DE.UTF-8 for all other LC_ variables,
> that is US English text but German locality).

Can you confirm that it errors out here:

                        int len = strspn(arg, "0123456789.");
                        char sv = arg[len];
                        arg[len] = '\0';
                        errno = 0;
                        d = strtod(arg, &pp);
                        if (errno || *pp)
                                bb_show_usage();

and if it does, put

bb_error_msg_and_die("arg:'%s' errno:%d pp:'%s'", arg, errno, pp)

there instead of bb_show_usage() and let me know what it prints.

> I tried even using comma as fractional separator (0,5s), which would be
> worse, as it breaks existing scripts, but that one gives an invalid
> number format error message.
>
> busybox-1.17.2> ./busybox sleep 0.5s
> BusyBox v1.17.2 (2010-09-23 16:39:29 CEST) multi-call binary.
>
> Usage: sleep [N]...
>
> Pause for a time equal to the total of the args given, where each arg can
> have an optional suffix of (s)econds, (m)inutes, (h)ours, or (d)ays
>
> busybox-1.17.2> ./busybox sleep 0,5s
> sleep: invalid number '0,5s'
> busybox-1.17.2> env|egrep 'LANG|LC_'
> LC_PAPER=de_DE.UTF-8
> LC_ADDRESS=de_DE.UTF-8
> LC_MONETARY=de_DE.UTF-8
> LC_NUMERIC=de_DE.UTF-8
> LC_TELEPHONE=de_DE.UTF-8
> LC_MESSAGES=en_US.UTF-8
> LC_COLLATE=de_DE.UTF-8
> LC_IDENTIFICATION=de_DE.UTF-8
> LANG=en_US.UTF-8
> LC_MEASUREMENT=de_DE.UTF-8
> LC_CTYPE=de_DE.UTF-8
> LC_TIME=de_DE.UTF-8
> LC_NAME=de_DE.UTF-8

Cannot reproduce. I downloaded 1.17.2, did
make defconfig && make, then ran this script:

export LC_PAPER=de_DE.UTF-8
export LC_ADDRESS=de_DE.UTF-8
export LC_MONETARY=de_DE.UTF-8
export LC_NUMERIC=de_DE.UTF-8
export LC_TELEPHONE=de_DE.UTF-8
export LC_MESSAGES=en_US.UTF-8
export LC_COLLATE=de_DE.UTF-8
export LC_IDENTIFICATION=de_DE.UTF-8
export LANG=en_US.UTF-8
export LC_MEASUREMENT=de_DE.UTF-8
export LC_CTYPE=de_DE.UTF-8
export LC_TIME=de_DE.UTF-8
export LC_NAME=de_DE.UTF-8
./busybox sleep 0.1m

and it slept for 6 seconds.
-- 
vda


More information about the busybox mailing list