aboutsummaryrefslogtreecommitdiff
path: root/util/fluxbox-generate_menu.in
diff options
context:
space:
mode:
authorMathias Gumz <akira@fluxbox.org>2016-04-25 18:11:14 (GMT)
committerMathias Gumz <akira@fluxbox.org>2016-04-25 18:11:14 (GMT)
commita11035440c30eda5b14118694f6f9aa15c0105ea (patch)
treef8cf2508264244158040799b72ea658ff44e9abf /util/fluxbox-generate_menu.in
parent5d90b7984cb73ede2763346382fb6e038ae5d16d (diff)
downloadfluxbox-a11035440c30eda5b14118694f6f9aa15c0105ea.zip
fluxbox-a11035440c30eda5b14118694f6f9aa15c0105ea.tar.bz2
fix fbsetbg in combination with picky shells
in *BSD, /bin/sh is Almquist Shell(ash). the 'hash' built-in command of ash returns 0, always. 'hash' is not usable for find_it() function in util/fbsetbg and util/fluxbox-generate_menu.in. this patch changes the behavior of find_it(): when 'hash' is detected to not work correctly, switch back to 'which'. this patch is the work of Yamashiro, Jun and appeared first as patch-160 on sourceforge: https://sourceforge.net/p/fluxbox/patches/160/. i submit it on behalf of the author.
Diffstat (limited to 'util/fluxbox-generate_menu.in')
-rwxr-xr-xutil/fluxbox-generate_menu.in29
1 files changed, 22 insertions, 7 deletions
diff --git a/util/fluxbox-generate_menu.in b/util/fluxbox-generate_menu.in
index 085d622..d319098 100755
--- a/util/fluxbox-generate_menu.in
+++ b/util/fluxbox-generate_menu.in
@@ -145,13 +145,28 @@ testoption() {
145 esac 145 esac
146} 146}
147 147
148find_it() { 148# some shell's hash returns 0 always
149 [ -n "$1" ] && hash $1 2> /dev/null && shift && "$@" 149if hash this_program_does_not_exist-no_really-aA1zZ9 > /dev/null 2>&1; then
150} 150 # can't rely on return value
151 # ash / ksh
152 find_it() {
153 which "$1" > /dev/null 2>&1 && shift && "$@"
154 }
151 155
152find_it_options() { 156 find_it_options() {
153 [ -n "$1" ] && hash $1 2> /dev/null 157 which "$1" > /dev/null 2>&1
154} 158 }
159else
160 # can rely on return value
161 # bash / dash / zsh / sh on Solaris
162 find_it() {
163 [ -n "$1" ] && hash "$1" 2> /dev/null && shift && "$@"
164 }
165
166 find_it_options() {
167 [ -n "$1" ] && hash "$1" 2> /dev/null
168 }
169fi
155 170
156#echo "replaceWithinString: $1, $2, $3" >&2 171#echo "replaceWithinString: $1, $2, $3" >&2
157#echo ${1//$2/$3} # causes error in BSD even though not used 172#echo ${1//$2/$3} # causes error in BSD even though not used
@@ -203,7 +218,7 @@ convertIcon(){
203 if [ -f "${entry_icon}" ]; then 218 if [ -f "${entry_icon}" ]; then
204 : echo "File exists. To overwrite, type: convert \"$1\" \"$entry_icon\"" >&2 219 : echo "File exists. To overwrite, type: convert \"$1\" \"$entry_icon\"" >&2
205 else 220 else
206 if hash convert 2> /dev/null; then 221 if find_it_options convert; then
207 convert "$1" "$entry_icon" 222 convert "$1" "$entry_icon"
208 # echo convert "$1" , "$entry_icon" >> $ICONMAPPING 223 # echo convert "$1" , "$entry_icon" >> $ICONMAPPING
209 else 224 else