> > I'm sorry, but I'm going to have to open this discussion again: I just
> > don't understand how moving these simple, sometimes critical,
> > commandline utilities to ksh scripts is even close to reasonable.
>
> I completely agree.  Floating point support could've been trivially added
> to the existing trivial program.  It is not too late to reverse course.

Apropos ksh93 sleep and floating point parsing (and locales):

% echo $SHELL
/bin/tcsh

% locale
LANG=de_DE.ISO8859-1
LC_CTYPE=de_DE.ISO8859-1
LC_NUMERIC=de_DE.ISO8859-1
LC_TIME=de_DE.ISO8859-1
LC_COLLATE=de_DE.ISO8859-1
LC_MONETARY=de_DE.ISO8859-1
LC_MESSAGES=de_DE.ISO8859-1
LC_ALL=

% time sleep 1.5
0.00u 0.00s 0:15.01 0.0%

This surprises me a bit, it sleeps 10x longer than expected.

% time sleep 1,5
0.00u 0.00s 0:01.51 0.0%

Hmm, so sleep behaviour now depends on locale settings?
How do we write portable shell scripts?

% time env LC_NUMERIC=C sleep 1.5
0.00u 0.00s 0:15.01 0.0%

I'd have assumed that the floating point parser
obeys the LC_NUMERIC setting, but it seems to 
ignore it...

% time env LC_ALL=C sleep 1.5
0.00u 0.00s 0:01.51 0.0%

... but LC_ALL works?  Why not LC_NUMERIC?

Btw. on Linux & gnu coreutils sleep the floating 
point parser seems to ignore the LC_* settings...


In another environment with slightly different locale settings
(LANG / LC_MESSAGES):

> echo $SHELL
/bin/tcsh

> locale
LANG=
LC_CTYPE=de_DE.ISO8859-1
LC_NUMERIC=de_DE.ISO8859-1
LC_TIME=de_DE.ISO8859-1
LC_COLLATE=de_DE.ISO8859-1
LC_MONETARY=de_DE.ISO8859-1
LC_MESSAGES=de
LC_ALL=

> time sleep 1.5
0.00u 0.00s 0:15.02 0.0%

> time sleep 1,5
0.00u 0.00s 0:01.52 0.0%

> time env LC_NUMERIC=C sleep 1,5
Usage: sleep [ options ] seconds
0.00u 0.00s 0:00.01 0.0%

We get a usage message when it can't parse the
floating point value?

> time env LC_NUMERIC=C sleep 1.5
0.00u 0.00s 0:01.52 0.0%


% ksh93

j...@moritz:~$ locale
LANG=de_DE.ISO8859-1
LC_CTYPE=de_DE.ISO8859-1
LC_NUMERIC=de_DE.ISO8859-1
LC_TIME=de_DE.ISO8859-1
LC_COLLATE=de_DE.ISO8859-1
LC_MONETARY=de_DE.ISO8859-1
LC_MESSAGES=de_DE.ISO8859-1
LC_ALL=

j...@moritz:~$  time sleep 1.5                                                  
  

real    0m15,13s
user    0m0,00s
sys     0m0,00s

j...@moritz:~$ time sleep 1,5                                                   
  

real    0m1,55s
user    0m0,00s
sys     0m0,00s

j...@moritz:~$ time env LC_NUMERIC=C sleep 1.5                                  
  

real    0m1,52s
user    0m0,00s
sys     0m0,00s

j...@moritz:~$ time env LC_ALL=C sleep 1.5                                      
  

real    0m1,58s
user    0m0,00s
sys     0m0,00s
-- 
This message posted from opensolaris.org
_______________________________________________
tools-discuss mailing list
tools-discuss@opensolaris.org

Reply via email to