utils: remove bashisms

fbsetbg: The random number generation used 'time' shell internal, which
does not exist in all shells.  Allowing 'ps' output to be part of cksum
input will increase entropy and enhance quality of the randomness.

fbsetbg: The second fix is more important.  In posix shell there is no
'==' comparision operator.

fluxbox-generate_menu: There are no quarantees about echo accepting
options, so use 'printf' for more advanced outputing.
This commit is contained in:
Sami Kerola 2012-12-30 23:33:26 +00:00 committed by Mathias Gumz
parent e15dfaf463
commit dcdfdfd56b
2 changed files with 7 additions and 3 deletions

View file

@ -505,7 +505,11 @@ if [ "$option" = random ]; then
randomnumber=`random_number` randomnumber=`random_number`
# some shells don't support $RANDOM # some shells don't support $RANDOM
elif [ -z "$RANDOM" ]; then elif [ -z "$RANDOM" ]; then
randomnumber=`(echo $$ ;time ps; w ; date )2>&1 | cksum | cut -f1 -d' '` if [ -r /dev/urandom ]; then
randomnumber=`hexdump -n 2 -e '/2 "%u"' /dev/urandom`
else
randomnumber=`(echo $$; ps; w; date) 2>&1 | cksum | cut -f1 -d' '`
fi
else else
randomnumber="$RANDOM" randomnumber="$RANDOM"
fi fi
@ -526,7 +530,7 @@ fi
if [ ! -r "$wallpaper" ]; then if [ ! -r "$wallpaper" ]; then
if [ "$ignore_missing_wallpaper" == "true" ]; then if [ "$ignore_missing_wallpaper" = "true" ]; then
exit 0 exit 0
fi fi
message "Can't find wallpaper $wallpaper" message "Can't find wallpaper $wallpaper"

View file

@ -331,7 +331,7 @@ searchForIcon(){
if [ -f "$entry_icon" ]; then if [ -f "$entry_icon" ]; then
# if icon exists and entry does not already exists, add it # if icon exists and entry does not already exists, add it
if ! grep -q -m 1 "^.${entry_exec}.[[:space:]]*<.*/${icon_base}\....>" $ICONMAPPING 2> /dev/null; then if ! grep -q -m 1 "^.${entry_exec}.[[:space:]]*<.*/${icon_base}\....>" $ICONMAPPING 2> /dev/null; then
echo -e "\"${entry_exec}\" \t <${entry_icon}>" >> $ICONMAPPING printf "\"${entry_exec}\" \t <${entry_icon}>\n" >> $ICONMAPPING
else else
: echo "# mapping already exists for ${entry_exec}" >> $ICONMAPPING : echo "# mapping already exists for ${entry_exec}" >> $ICONMAPPING
fi fi