all repos — fluxbox @ b7d3dc2fa389706bde066219b11d3b66832cfa9e

custom fork of the fluxbox windowmanager

fix 'which' program compatibility.
Test the capabilities of the one we find, rather than guessing
based on the system type
simonb simonb
commit

b7d3dc2fa389706bde066219b11d3b66832cfa9e

parent

aa0a9cd50674fbf55ae05c29ae4cbb873f2c55c0

2 files changed, 59 insertions(+), 70 deletions(-)

jump to
M util/fbsetbgutil/fbsetbg

@@ -130,28 +130,28 @@

EOF } -# ugly code for solaris compat. -case `uname` in - Linux|*BSD) - find_it() { - which $1 > /dev/null 2>&1 && shift && $* - } - ;; - *) - find_it() { - file=`which $1 2> /dev/null` - if [ -x "$file" ]; then - if [ $# -gt 1 ]; then - shift - $* - fi - return 0 - else - return 1 +# some which's have a reliable return code, some don't +# Lets figure out which which we have. +if which this_program_does_not_exist-no_really-aA1zZ9 >/dev/null 2>/dev/null; then + # can't rely on return value + find_it() { + file=`which $1 2> /dev/null` + if [ -x "$file" ]; then + if [ $# -gt 1 ]; then + shift + $* fi - } - ;; -esac + return 0 + else + return 1 + fi + } +else + # can rely on return value + find_it() { + which $1 > /dev/null 2>&1 && shift && $* + } +fi message() {
M util/fluxbox-generate_menu.inutil/fluxbox-generate_menu.in

@@ -123,59 +123,48 @@

EOF } -# ugly code for solaris compat. -UNAME=`uname` -# echo "UNAME=$UNAME" -case "$UNAME" in - Linux|*BSD) - find_it() { - which $1 > /dev/null 2>&1 && shift && $* - } +# some which's have a reliable return code, some don't +# Lets figure out which which we have. +if which this_program_does_not_exist-no_really-aA1zZ9 >/dev/null 2>/dev/null; then + # can't rely on return value + find_it() { + file=`which $1 2> /dev/null` + if [ -x "$file" ]; then + if [ $# -gt 1 ]; then + shift + $* + fi + return 0 + else + return 1 + fi + } - find_it_options() { - which $1 > /dev/null 2>&1 - } - ;; - *) - find_it() { - file=`which $1 2> /dev/null` - if [ -x "$file" ]; then - if [ $# -gt 1 ]; then - shift - $* - fi - return 0 - else - return 1 - fi - } + find_it_options() { + file=`which $1 2> /dev/null` + if [ -x "$file" ]; then + return 0 + else + return 1 + fi + } - find_it_options() { - file=`which $1 2> /dev/null` - if [ -x "$file" ]; then - return 0 - else - return 1 - fi - } +else + # can rely on return value + find_it() { + which $1 > /dev/null 2>&1 && shift && $* + } - ;; -esac + find_it_options() { + which $1 > /dev/null 2>&1 + } +fi -case "$UNAME" in - Linux) - replaceWithinString(){ - #echo "replaceWithinString: $1, $2, $3" >&2 - #echo ${1//$2/$3} # causes error in BSD even though not used - echo $1 | awk "{ gsub(/$2/, \"$3\"); print }" - } - ;; - *BSD) - replaceWithinString(){ - echo $1 | awk "{ gsub(/$2/, \"$3\"); print }" - } - ;; -esac +#echo "replaceWithinString: $1, $2, $3" >&2 +#echo ${1//$2/$3} # causes error in BSD even though not used +replaceWithinString(){ + echo $1 | awk "{ gsub(/$2/, \"$3\"); print }" +} convertIcon(){ if [ ! -f "$1" ] ; then