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.
This commit is contained in:
parent
5d90b7984c
commit
a11035440c
2 changed files with 36 additions and 10 deletions
17
util/fbsetbg
17
util/fbsetbg
|
@ -133,9 +133,20 @@ Common tips to use with $command:
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
find_it() {
|
# some shell's hash returns 0 always
|
||||||
[ -n "$1" ] && hash $1 2> /dev/null
|
if hash this_program_does_not_exist-no_really-aA1zZ9 > /dev/null 2>&1; then
|
||||||
}
|
# can't rely on return value
|
||||||
|
# ash / ksh
|
||||||
|
find_it() {
|
||||||
|
which "$1" > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
# can rely on return value
|
||||||
|
# bash / dash / zsh / sh on Solaris
|
||||||
|
find_it() {
|
||||||
|
[ -n "$1" ] && hash "$1" 2> /dev/null
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
message() {
|
message() {
|
||||||
|
|
||||||
|
|
|
@ -145,13 +145,28 @@ testoption() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
find_it() {
|
# some shell's hash returns 0 always
|
||||||
[ -n "$1" ] && hash $1 2> /dev/null && shift && "$@"
|
if hash this_program_does_not_exist-no_really-aA1zZ9 > /dev/null 2>&1; then
|
||||||
}
|
# can't rely on return value
|
||||||
|
# ash / ksh
|
||||||
|
find_it() {
|
||||||
|
which "$1" > /dev/null 2>&1 && shift && "$@"
|
||||||
|
}
|
||||||
|
|
||||||
find_it_options() {
|
find_it_options() {
|
||||||
[ -n "$1" ] && hash $1 2> /dev/null
|
which "$1" > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
# can rely on return value
|
||||||
|
# bash / dash / zsh / sh on Solaris
|
||||||
|
find_it() {
|
||||||
|
[ -n "$1" ] && hash "$1" 2> /dev/null && shift && "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
find_it_options() {
|
||||||
|
[ -n "$1" ] && hash "$1" 2> /dev/null
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
#echo "replaceWithinString: $1, $2, $3" >&2
|
#echo "replaceWithinString: $1, $2, $3" >&2
|
||||||
#echo ${1//$2/$3} # causes error in BSD even though not used
|
#echo ${1//$2/$3} # causes error in BSD even though not used
|
||||||
|
@ -203,7 +218,7 @@ convertIcon(){
|
||||||
if [ -f "${entry_icon}" ]; then
|
if [ -f "${entry_icon}" ]; then
|
||||||
: echo "File exists. To overwrite, type: convert \"$1\" \"$entry_icon\"" >&2
|
: echo "File exists. To overwrite, type: convert \"$1\" \"$entry_icon\"" >&2
|
||||||
else
|
else
|
||||||
if hash convert 2> /dev/null; then
|
if find_it_options convert; then
|
||||||
convert "$1" "$entry_icon"
|
convert "$1" "$entry_icon"
|
||||||
# echo convert "$1" , "$entry_icon" >> $ICONMAPPING
|
# echo convert "$1" , "$entry_icon" >> $ICONMAPPING
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue