aboutsummaryrefslogtreecommitdiff
path: root/util/fluxbox-generate_menu.in
diff options
context:
space:
mode:
authorsimonb <simonb>2005-03-10 13:53:26 (GMT)
committersimonb <simonb>2005-03-10 13:53:26 (GMT)
commitb7d3dc2fa389706bde066219b11d3b66832cfa9e (patch)
treebef84fcad42c7788ff3473b9f8a6f51c4e33ed8e /util/fluxbox-generate_menu.in
parentaa0a9cd50674fbf55ae05c29ae4cbb873f2c55c0 (diff)
downloadfluxbox-b7d3dc2fa389706bde066219b11d3b66832cfa9e.zip
fluxbox-b7d3dc2fa389706bde066219b11d3b66832cfa9e.tar.bz2
fix 'which' program compatibility.
Test the capabilities of the one we find, rather than guessing based on the system type
Diffstat (limited to 'util/fluxbox-generate_menu.in')
-rwxr-xr-xutil/fluxbox-generate_menu.in87
1 files changed, 38 insertions, 49 deletions
diff --git a/util/fluxbox-generate_menu.in b/util/fluxbox-generate_menu.in
index 5a38247..d77b44b 100755
--- a/util/fluxbox-generate_menu.in
+++ b/util/fluxbox-generate_menu.in
@@ -123,59 +123,48 @@ fluxbox-generate_menu was brought to you by:
123EOF 123EOF
124} 124}
125 125
126# ugly code for solaris compat. 126# some which's have a reliable return code, some don't
127UNAME=`uname` 127# Lets figure out which which we have.
128# echo "UNAME=$UNAME" 128if which this_program_does_not_exist-no_really-aA1zZ9 >/dev/null 2>/dev/null; then
129case "$UNAME" in 129 # can't rely on return value
130 Linux|*BSD) 130 find_it() {
131 find_it() { 131 file=`which $1 2> /dev/null`
132 which $1 > /dev/null 2>&1 && shift && $* 132 if [ -x "$file" ]; then
133 } 133 if [ $# -gt 1 ]; then
134 134 shift
135 find_it_options() { 135 $*
136 which $1 > /dev/null 2>&1
137 }
138 ;;
139 *)
140 find_it() {
141 file=`which $1 2> /dev/null`
142 if [ -x "$file" ]; then
143 if [ $# -gt 1 ]; then
144 shift
145 $*
146 fi
147 return 0
148 else
149 return 1
150 fi 136 fi
151 } 137 return 0
138 else
139 return 1
140 fi
141 }
152 142
153 find_it_options() { 143 find_it_options() {
154 file=`which $1 2> /dev/null` 144 file=`which $1 2> /dev/null`
155 if [ -x "$file" ]; then 145 if [ -x "$file" ]; then
156 return 0 146 return 0
157 else 147 else
158 return 1 148 return 1
159 fi 149 fi
160 } 150 }
161 151
162 ;; 152else
163esac 153 # can rely on return value
154 find_it() {
155 which $1 > /dev/null 2>&1 && shift && $*
156 }
164 157
165case "$UNAME" in 158 find_it_options() {
166 Linux) 159 which $1 > /dev/null 2>&1
167 replaceWithinString(){ 160 }
168 #echo "replaceWithinString: $1, $2, $3" >&2 161fi
169 #echo ${1//$2/$3} # causes error in BSD even though not used 162
170 echo $1 | awk "{ gsub(/$2/, \"$3\"); print }" 163#echo "replaceWithinString: $1, $2, $3" >&2
171 } 164#echo ${1//$2/$3} # causes error in BSD even though not used
172 ;; 165replaceWithinString(){
173 *BSD) 166 echo $1 | awk "{ gsub(/$2/, \"$3\"); print }"
174 replaceWithinString(){ 167}
175 echo $1 | awk "{ gsub(/$2/, \"$3\"); print }"
176 }
177 ;;
178esac
179 168
180convertIcon(){ 169convertIcon(){
181 if [ ! -f "$1" ] ; then 170 if [ ! -f "$1" ] ; then