all repos — fluxbox @ 7525226fe2fdf9ea2461311c98aa820fddc39e77

custom fork of the fluxbox windowmanager

less bashisms in fluxbox-generate_menu

still works with bash or zsh, but fish (now) complains about "cat << EOF" ...

no "grep -q"
BUG: 961

echo is troublesome
POSIX doesn't know a "local" keyword
BUG: 975

seems double comments ## aren't supported everywhere
BUG: 1057
Thomas Lübking thomas.luebking@gmail.com
commit

7525226fe2fdf9ea2461311c98aa820fddc39e77

parent

abd5c9e478ac99f457a1df6292729b615f58bbda

1 files changed, 10 insertions(+), 9 deletions(-)

jump to
M util/fluxbox-generate_menu.inutil/fluxbox-generate_menu.in

@@ -35,9 +35,11 @@ # - don't use ~, use ${HOME}

# - don't use id -u or $UID, use whoami # - getopts won't work on all platforms, but the config-file can # compensate for that. -# - OpenBSD and Solaris grep do not have the -m option +# - OpenBSD and Solaris grep do not have the -m or -q options # - various software like grep/sed/perl may be not present or not # the version you have. for example grep '\W' only works on gnu-grep. +# - echo can lack several flags (notably -n) and might default to absent -e +# In doubt, use printf # Keep this in mind, use bare basic defaults. # - Do _NOT_ suggest to use #!/bin/bash. Not everybody uses bash. # Non portable features like getopts in this script can be achieved in

@@ -186,7 +188,6 @@ # not really an error; just nothing to do.

return 0; fi - local BASENAME BASENAME="${1##*/}" # make sure it is an icon by checking if it has an extension

@@ -246,7 +247,7 @@ }

doSearchLoop(){ for ICONPATH in "$@"; do - ## $dnlamVERBOSE ": $ICONPATH" >> $ICONMAPPING + # $dnlamVERBOSE ": $ICONPATH" >> $ICONMAPPING [ -d "$ICONPATH" ] || continue #echo -n "." # # $dnlamVERBOSE ":: $ICONPATH/$temp_icon" >> $ICONMAPPING

@@ -257,7 +258,7 @@ else # try different extensions;

# remove extension iconNOext="${temp_icon%%.*}" [ -d "$ICONPATH" ] && for ICONEXT in .xpm .png .gif ; do - ## echo "::: $ICONPATH/$iconNOext$ICONEXT" >> $ICONMAPPING + # echo "::: $ICONPATH/$iconNOext$ICONEXT" >> $ICONMAPPING realpath=`find "$ICONPATH" -type f -name "$iconNOext$ICONEXT" | head -n 1` if [ -n "$realpath" ]; then echo $realpath

@@ -345,7 +346,7 @@ icon_base="${icon_base%%.*}"

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

@@ -417,7 +418,7 @@ iconString=`grep "^\"${execname%% *}" $ICONMAPPING | head -n 1 | grep -o '<.*>'`

fi if [ -z "$iconString" ] && [ -z "$PARSING_DESKTOP" ] ; then - ## $dnlamVERBOSE "lookupIcon: Searching ... should only be needed for icons not gotten from *.desktop (manual-created ones): $execname" >&2 + # $dnlamVERBOSE "lookupIcon: Searching ... should only be needed for icons not gotten from *.desktop (manual-created ones): $execname" >&2 searchForIcon "$execname" "$execname" [ -n "$entry_icon" ] && iconString="<$entry_icon>" fi

@@ -432,7 +433,7 @@ # $dnlamVERBOSE echo "append: $*" >&2

iconString="`echo $* | grep -o '<.*>'`" # echo "iconString=$iconString" >&2 if [ -z "$iconString" ] && [ -z "$NO_ICON" ]; then - echo -n " $* " >> ${MENUFILENAME} + printf " $* " >> ${MENUFILENAME} # get the program name between '{}' from parameters execname="$*" execname=${execname#*\{}

@@ -576,7 +577,7 @@ WHOAMI=`whoami`

[ "$WHOAMI" = root ] && PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin # Check for Imlib2-support -if @pkgprefix@fluxbox@pkgsuffix@@EXEEXT@ -info 2> /dev/null | grep -q "^IMLIB"; then +if @pkgprefix@fluxbox@pkgsuffix@@EXEEXT@ -info 2> /dev/null | grep "^IMLIB" >/dev/null 2>&1; then PNG_ICONS="yes" else # better assume to assume "no"

@@ -1473,7 +1474,7 @@ [ "$GNOMEMENU$KDEMENU" ] && OTHER_DESKTOP_PATHS="\"$ETCAPPLNK\" $OTHER_DESKTOP_PATHS"

checkDirs(){ #echo checkDirs: $* >&2 - local CHECKED_DIRS="" + CHECKED_DIRS="" for DIR in "$@"; do if [ -d "$DIR" ]; then # todo: should check if there are duplicates