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
This commit is contained in:
parent
abd5c9e478
commit
7525226fe2
1 changed files with 10 additions and 9 deletions
|
@ -35,9 +35,11 @@
|
||||||
# - don't use id -u or $UID, use whoami
|
# - don't use id -u or $UID, use whoami
|
||||||
# - getopts won't work on all platforms, but the config-file can
|
# - getopts won't work on all platforms, but the config-file can
|
||||||
# compensate for that.
|
# 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
|
# - 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.
|
# 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.
|
# Keep this in mind, use bare basic defaults.
|
||||||
# - Do _NOT_ suggest to use #!/bin/bash. Not everybody uses bash.
|
# - Do _NOT_ suggest to use #!/bin/bash. Not everybody uses bash.
|
||||||
# Non portable features like getopts in this script can be achieved in
|
# Non portable features like getopts in this script can be achieved in
|
||||||
|
@ -186,7 +188,6 @@ convertIcon(){
|
||||||
return 0;
|
return 0;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local BASENAME
|
|
||||||
BASENAME="${1##*/}"
|
BASENAME="${1##*/}"
|
||||||
|
|
||||||
# make sure it is an icon by checking if it has an extension
|
# make sure it is an icon by checking if it has an extension
|
||||||
|
@ -246,7 +247,7 @@ removePath(){
|
||||||
|
|
||||||
doSearchLoop(){
|
doSearchLoop(){
|
||||||
for ICONPATH in "$@"; do
|
for ICONPATH in "$@"; do
|
||||||
## $dnlamVERBOSE ": $ICONPATH" >> $ICONMAPPING
|
# $dnlamVERBOSE ": $ICONPATH" >> $ICONMAPPING
|
||||||
[ -d "$ICONPATH" ] || continue
|
[ -d "$ICONPATH" ] || continue
|
||||||
#echo -n "."
|
#echo -n "."
|
||||||
# # $dnlamVERBOSE ":: $ICONPATH/$temp_icon" >> $ICONMAPPING
|
# # $dnlamVERBOSE ":: $ICONPATH/$temp_icon" >> $ICONMAPPING
|
||||||
|
@ -257,7 +258,7 @@ doSearchLoop(){
|
||||||
# remove extension
|
# remove extension
|
||||||
iconNOext="${temp_icon%%.*}"
|
iconNOext="${temp_icon%%.*}"
|
||||||
[ -d "$ICONPATH" ] && for ICONEXT in .xpm .png .gif ; do
|
[ -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`
|
realpath=`find "$ICONPATH" -type f -name "$iconNOext$ICONEXT" | head -n 1`
|
||||||
if [ -n "$realpath" ]; then
|
if [ -n "$realpath" ]; then
|
||||||
echo $realpath
|
echo $realpath
|
||||||
|
@ -345,7 +346,7 @@ searchForIcon(){
|
||||||
# echo "^.${entry_exec}.[[:space:]]*<.*/${icon_base}\....>"
|
# echo "^.${entry_exec}.[[:space:]]*<.*/${icon_base}\....>"
|
||||||
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 "^.${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
|
printf "\"${execname}\" \t <${entry_icon}>\n" >> $ICONMAPPING
|
||||||
else
|
else
|
||||||
: echo "# mapping already exists for ${execname}" >> $ICONMAPPING
|
: echo "# mapping already exists for ${execname}" >> $ICONMAPPING
|
||||||
|
@ -417,7 +418,7 @@ lookupIcon() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$iconString" ] && [ -z "$PARSING_DESKTOP" ] ; then
|
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"
|
searchForIcon "$execname" "$execname"
|
||||||
[ -n "$entry_icon" ] && iconString="<$entry_icon>"
|
[ -n "$entry_icon" ] && iconString="<$entry_icon>"
|
||||||
fi
|
fi
|
||||||
|
@ -432,7 +433,7 @@ append() {
|
||||||
iconString="`echo $* | grep -o '<.*>'`"
|
iconString="`echo $* | grep -o '<.*>'`"
|
||||||
# echo "iconString=$iconString" >&2
|
# echo "iconString=$iconString" >&2
|
||||||
if [ -z "$iconString" ] && [ -z "$NO_ICON" ]; then
|
if [ -z "$iconString" ] && [ -z "$NO_ICON" ]; then
|
||||||
echo -n " $* " >> ${MENUFILENAME}
|
printf " $* " >> ${MENUFILENAME}
|
||||||
# get the program name between '{}' from parameters
|
# get the program name between '{}' from parameters
|
||||||
execname="$*"
|
execname="$*"
|
||||||
execname=${execname#*\{}
|
execname=${execname#*\{}
|
||||||
|
@ -576,7 +577,7 @@ WHOAMI=`whoami`
|
||||||
[ "$WHOAMI" = root ] && PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
|
[ "$WHOAMI" = root ] && PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
|
||||||
|
|
||||||
# Check for Imlib2-support
|
# 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"
|
PNG_ICONS="yes"
|
||||||
else
|
else
|
||||||
# better assume to assume "no"
|
# better assume to assume "no"
|
||||||
|
@ -1473,7 +1474,7 @@ if [ -z "${INSTALL}" ] && [ -z "${NO_ICON}" ]; then
|
||||||
|
|
||||||
checkDirs(){
|
checkDirs(){
|
||||||
#echo checkDirs: $* >&2
|
#echo checkDirs: $* >&2
|
||||||
local CHECKED_DIRS=""
|
CHECKED_DIRS=""
|
||||||
for DIR in "$@"; do
|
for DIR in "$@"; do
|
||||||
if [ -d "$DIR" ]; then
|
if [ -d "$DIR" ]; then
|
||||||
# todo: should check if there are duplicates
|
# todo: should check if there are duplicates
|
||||||
|
|
Loading…
Reference in a new issue