From dcdfdfd56b5dbb6453062ad60876647b11433f18 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 30 Dec 2012 23:33:26 +0000 Subject: [PATCH] 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. --- util/fbsetbg | 8 ++++++-- util/fluxbox-generate_menu.in | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/util/fbsetbg b/util/fbsetbg index 0bdb804a..e2773171 100644 --- a/util/fbsetbg +++ b/util/fbsetbg @@ -505,7 +505,11 @@ if [ "$option" = random ]; then randomnumber=`random_number` # some shells don't support $RANDOM 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 randomnumber="$RANDOM" fi @@ -526,7 +530,7 @@ fi if [ ! -r "$wallpaper" ]; then - if [ "$ignore_missing_wallpaper" == "true" ]; then + if [ "$ignore_missing_wallpaper" = "true" ]; then exit 0 fi message "Can't find wallpaper $wallpaper" diff --git a/util/fluxbox-generate_menu.in b/util/fluxbox-generate_menu.in index 63c152ea..eb6414ce 100755 --- a/util/fluxbox-generate_menu.in +++ b/util/fluxbox-generate_menu.in @@ -331,7 +331,7 @@ searchForIcon(){ if [ -f "$entry_icon" ]; then # 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 - echo -e "\"${entry_exec}\" \t <${entry_icon}>" >> $ICONMAPPING + printf "\"${entry_exec}\" \t <${entry_icon}>\n" >> $ICONMAPPING else : echo "# mapping already exists for ${entry_exec}" >> $ICONMAPPING fi