all repos — fluxbox @ ed96d79a14f3078a291bc569c6c5f8926eacdbb3

custom fork of the fluxbox windowmanager

command -v seems to cause problems for some distros, despite being POSIX and built into sh
markt markt
commit

ed96d79a14f3078a291bc569c6c5f8926eacdbb3

parent

3d789a1e709f87170398b525643794cf6ff52fde

3 files changed, 60 insertions(+), 14 deletions(-)

jump to
M ChangeLogChangeLog

@@ -216,8 +216,6 @@ *07/01/03:

* Don't run [startup] items in apps file on fluxbox restart (Mark) Remember.cc fluxbox.cc *07/01/02: - * Replace `which' in fbsetbg and fbgm with `command -v' (Mark) - util/fbsetbg fluxbox-generate_menu.in * Don't escape regular expression metacharacters in apps file, bug #1595497 (Mark) Remember.cc ClientPattern.cc
M util/fbsetbgutil/fbsetbg

@@ -131,9 +131,28 @@

EOF } -find_it() { - command -v $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 + } +else + # can rely on return value + find_it() { + which $1 > /dev/null 2>&1 && shift && $* + } +fi message() {

@@ -330,7 +349,7 @@ if find_it $wpsetter; then

if [ ! "$wpsetter" = Esetroot ]; then WPSETTER=$wpsetter break - elif ldd `command -v Esetroot`|grep libImlib 2>&1 > /dev/null; then + elif ldd `which Esetroot`|grep libImlib 2>&1 > /dev/null; then WPSETTER=$wpsetter break else
M util/fluxbox-generate_menu.inutil/fluxbox-generate_menu.in

@@ -124,13 +124,42 @@

EOF } -find_it() { - command -v $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 2> /dev/null 1> /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() { + file=`which $1 2> /dev/null` + if [ -x "$file" ]; then + return 0 + else + return 1 + fi + } -find_it_options() { - command -v $1 > /dev/null 2>&1 -} +else + # can rely on return value + find_it() { + which $1 > /dev/null 2>&1 && shift && "$@" + } + + find_it_options() { + which $1 > /dev/null 2>&1 + } +fi #echo "replaceWithinString: $1, $2, $3" >&2 #echo ${1//$2/$3} # causes error in BSD even though not used

@@ -182,7 +211,7 @@ entry_icon="$2/${BASENAME%.*}.xpm"

if [ -f "${entry_icon}" ]; then : echo "File exists. To overwrite, type: convert \"$1\" \"$entry_icon\"" >&2 else - if command -v convert &> /dev/null; then + if which convert &> /dev/null; then convert "$1" "$entry_icon" # echo convert "$1" , "$entry_icon" >> $ICONMAPPING else

@@ -1349,7 +1378,7 @@

# prefix PREFIX="${PREFIX:=@PREFIX@}" if [ -z "${PREFIX}" -o ! -d "${PREFIX}" ]; then - PREFIX=`command -v fluxbox | sed 's,/bin/fluxbox$,,'` + PREFIX=`which fluxbox | sed 's,/bin/fluxbox$,,'` fi