fix 'which' program compatibility.
Test the capabilities of the one we find, rather than guessing based on the system type
This commit is contained in:
parent
aa0a9cd506
commit
b7d3dc2fa3
2 changed files with 59 additions and 70 deletions
42
util/fbsetbg
42
util/fbsetbg
|
@ -130,28 +130,28 @@ Common tips to use with $command:
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# ugly code for solaris compat.
|
# some which's have a reliable return code, some don't
|
||||||
case `uname` in
|
# Lets figure out which which we have.
|
||||||
Linux|*BSD)
|
if which this_program_does_not_exist-no_really-aA1zZ9 >/dev/null 2>/dev/null; then
|
||||||
find_it() {
|
# can't rely on return value
|
||||||
which $1 > /dev/null 2>&1 && shift && $*
|
find_it() {
|
||||||
}
|
file=`which $1 2> /dev/null`
|
||||||
;;
|
if [ -x "$file" ]; then
|
||||||
*)
|
if [ $# -gt 1 ]; then
|
||||||
find_it() {
|
shift
|
||||||
file=`which $1 2> /dev/null`
|
$*
|
||||||
if [ -x "$file" ]; then
|
|
||||||
if [ $# -gt 1 ]; then
|
|
||||||
shift
|
|
||||||
$*
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
}
|
return 0
|
||||||
;;
|
else
|
||||||
esac
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
else
|
||||||
|
# can rely on return value
|
||||||
|
find_it() {
|
||||||
|
which $1 > /dev/null 2>&1 && shift && $*
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
message() {
|
message() {
|
||||||
|
|
||||||
|
|
|
@ -123,59 +123,48 @@ fluxbox-generate_menu was brought to you by:
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# ugly code for solaris compat.
|
# some which's have a reliable return code, some don't
|
||||||
UNAME=`uname`
|
# Lets figure out which which we have.
|
||||||
# echo "UNAME=$UNAME"
|
if which this_program_does_not_exist-no_really-aA1zZ9 >/dev/null 2>/dev/null; then
|
||||||
case "$UNAME" in
|
# can't rely on return value
|
||||||
Linux|*BSD)
|
find_it() {
|
||||||
find_it() {
|
file=`which $1 2> /dev/null`
|
||||||
which $1 > /dev/null 2>&1 && shift && $*
|
if [ -x "$file" ]; then
|
||||||
}
|
if [ $# -gt 1 ]; then
|
||||||
|
shift
|
||||||
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
|
fi
|
||||||
}
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
find_it_options() {
|
find_it_options() {
|
||||||
file=`which $1 2> /dev/null`
|
file=`which $1 2> /dev/null`
|
||||||
if [ -x "$file" ]; then
|
if [ -x "$file" ]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
;;
|
else
|
||||||
esac
|
# can rely on return value
|
||||||
|
find_it() {
|
||||||
|
which $1 > /dev/null 2>&1 && shift && $*
|
||||||
|
}
|
||||||
|
|
||||||
case "$UNAME" in
|
find_it_options() {
|
||||||
Linux)
|
which $1 > /dev/null 2>&1
|
||||||
replaceWithinString(){
|
}
|
||||||
#echo "replaceWithinString: $1, $2, $3" >&2
|
fi
|
||||||
#echo ${1//$2/$3} # causes error in BSD even though not used
|
|
||||||
echo $1 | awk "{ gsub(/$2/, \"$3\"); print }"
|
#echo "replaceWithinString: $1, $2, $3" >&2
|
||||||
}
|
#echo ${1//$2/$3} # causes error in BSD even though not used
|
||||||
;;
|
replaceWithinString(){
|
||||||
*BSD)
|
echo $1 | awk "{ gsub(/$2/, \"$3\"); print }"
|
||||||
replaceWithinString(){
|
}
|
||||||
echo $1 | awk "{ gsub(/$2/, \"$3\"); print }"
|
|
||||||
}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
convertIcon(){
|
convertIcon(){
|
||||||
if [ ! -f "$1" ] ; then
|
if [ ! -f "$1" ] ; then
|
||||||
|
|
Loading…
Reference in a new issue