Bug#480597: fluxbox: bashism in /bin/sh script

2008-12-02 Thread Andres Mejia
tags 480597 = patch
thanks

This script will fail in dash if the program 'time' is not installed. You can 
check for yourself.

$ dash -c 'command -V time'
time is /usr/bin/time

I've provided a patch that checks for 'time' to be installed and if not, falls 
back to a different method of generating a random number that doesn't use 
$RANDOM.

-- 
Regards,
Andres
--- fluxbox-1.1.1/build-tree/fluxbox-1.1.1/util/fbsetbg.old	2008-12-02 21:07:53.0 -0500
+++ fluxbox-1.1.1/build-tree/fluxbox-1.1.1/util/fbsetbg	2008-12-02 21:19:47.0 -0500
@@ -498,11 +498,11 @@
 number_of_wallpapers=`ls $wallpaperdir|wc -l`
 if find_it random_number; then
 randomnumber=`random_number`
-# some shells don't support $RANDOM
-elif [ -z $RANDOM ]; then
+# check if the program 'time' is available
+elif [ $(command -v time) ]; then
 randomnumber=`(echo $$ ;time ps; w ; date )21 | cksum | cut -f1 -d' '`
 else
-randomnumber=$RANDOM
+randomnumber=$(dd if=/dev/urandom count=1 2 /dev/null | cksum | cut -f1 -d  )
 fi
 wallpapernumber=`expr $randomnumber % $number_of_wallpapers + 1`
 #remember previous wallpaper


signature.asc
Description: This is a digitally signed message part.


Bug#480597: fluxbox: bashism in /bin/sh script

2008-05-17 Thread Dmitry E. Oboukhov
tag 480597 unreproducible
thanks

I think that it was not a good idea to remove unreproducible
tag from the bug.

I haven't found  any  way  of  running  fbsetbg  with  error
occurring.  Yes,  if  there  is  not  present  some  utility
(time/echo/date) then the error will be outputted  to  pipe,
but   this   error   willbeapartofrandom
generator.

It will work even in case when 2 of 3 utilities  are  absent
(that can't be in reality) Make *retitle bug* to 'my way  of
fbsetbg optimizing' ;) or give a way of using  fbsetbg  with
which the error will appear.  While you are thinking  I  set
unreproducible tag :)  

PS: Of course I would write it this way: 

dd if=/dev/urandom bs=100 count=1 21|cksum... 

but for our case in my opinion it's enougth jus one variable
$$

Dmitry


signature.asc
Description: Digital signature