diff options
author | markt <markt> | 2007-02-22 16:51:35 (GMT) |
---|---|---|
committer | markt <markt> | 2007-02-22 16:51:35 (GMT) |
commit | ed96d79a14f3078a291bc569c6c5f8926eacdbb3 (patch) | |
tree | 5742a05a01da5323632549205ad52ce44a2aa1ac /util | |
parent | 3d789a1e709f87170398b525643794cf6ff52fde (diff) | |
download | fluxbox_pavel-ed96d79a14f3078a291bc569c6c5f8926eacdbb3.zip fluxbox_pavel-ed96d79a14f3078a291bc569c6c5f8926eacdbb3.tar.bz2 |
command -v seems to cause problems for some distros, despite being POSIX and built into sh
Diffstat (limited to 'util')
-rw-r--r-- | util/fbsetbg | 27 | ||||
-rwxr-xr-x | util/fluxbox-generate_menu.in | 45 |
2 files changed, 60 insertions, 12 deletions
diff --git a/util/fbsetbg b/util/fbsetbg index 917f89a..60118e5 100644 --- a/util/fbsetbg +++ b/util/fbsetbg | |||
@@ -131,9 +131,28 @@ Common tips to use with $command: | |||
131 | EOF | 131 | EOF |
132 | } | 132 | } |
133 | 133 | ||
134 | find_it() { | 134 | # some which's have a reliable return code, some don't |
135 | command -v $1 > /dev/null 2>&1 && shift && $* | 135 | # Lets figure out which which we have. |
136 | } | 136 | if which this_program_does_not_exist-no_really-aA1zZ9 >/dev/null 2>/dev/null; then |
137 | # can't rely on return value | ||
138 | find_it() { | ||
139 | file=`which $1 2> /dev/null` | ||
140 | if [ -x "$file" ]; then | ||
141 | if [ $# -gt 1 ]; then | ||
142 | shift | ||
143 | $* | ||
144 | fi | ||
145 | return 0 | ||
146 | else | ||
147 | return 1 | ||
148 | fi | ||
149 | } | ||
150 | else | ||
151 | # can rely on return value | ||
152 | find_it() { | ||
153 | which $1 > /dev/null 2>&1 && shift && $* | ||
154 | } | ||
155 | fi | ||
137 | 156 | ||
138 | message() { | 157 | message() { |
139 | 158 | ||
@@ -330,7 +349,7 @@ if [ "$setterfromcommandline" != true ]; then | |||
330 | if [ ! "$wpsetter" = Esetroot ]; then | 349 | if [ ! "$wpsetter" = Esetroot ]; then |
331 | WPSETTER=$wpsetter | 350 | WPSETTER=$wpsetter |
332 | break | 351 | break |
333 | elif ldd `command -v Esetroot`|grep libImlib 2>&1 > /dev/null; then | 352 | elif ldd `which Esetroot`|grep libImlib 2>&1 > /dev/null; then |
334 | WPSETTER=$wpsetter | 353 | WPSETTER=$wpsetter |
335 | break | 354 | break |
336 | else | 355 | else |
diff --git a/util/fluxbox-generate_menu.in b/util/fluxbox-generate_menu.in index cd168fc..80a2af2 100755 --- a/util/fluxbox-generate_menu.in +++ b/util/fluxbox-generate_menu.in | |||
@@ -124,13 +124,42 @@ fluxbox-generate_menu was brought to you by: | |||
124 | EOF | 124 | EOF |
125 | } | 125 | } |
126 | 126 | ||
127 | find_it() { | 127 | # some which's have a reliable return code, some don't |
128 | command -v $1 > /dev/null 2>&1 && shift && "$@" | 128 | # Lets figure out which which we have. |
129 | } | 129 | if which this_program_does_not_exist-no_really-aA1zZ9 2> /dev/null 1> /dev/null; then |
130 | # can't rely on return value | ||
131 | find_it() { | ||
132 | file=`which $1 2> /dev/null` | ||
133 | if [ -x "$file" ]; then | ||
134 | if [ $# -gt 1 ]; then | ||
135 | shift | ||
136 | "$@" | ||
137 | fi | ||
138 | return 0 | ||
139 | else | ||
140 | return 1 | ||
141 | fi | ||
142 | } | ||
130 | 143 | ||
131 | find_it_options() { | 144 | find_it_options() { |
132 | command -v $1 > /dev/null 2>&1 | 145 | file=`which $1 2> /dev/null` |
133 | } | 146 | if [ -x "$file" ]; then |
147 | return 0 | ||
148 | else | ||
149 | return 1 | ||
150 | fi | ||
151 | } | ||
152 | |||
153 | else | ||
154 | # can rely on return value | ||
155 | find_it() { | ||
156 | which $1 > /dev/null 2>&1 && shift && "$@" | ||
157 | } | ||
158 | |||
159 | find_it_options() { | ||
160 | which $1 > /dev/null 2>&1 | ||
161 | } | ||
162 | fi | ||
134 | 163 | ||
135 | #echo "replaceWithinString: $1, $2, $3" >&2 | 164 | #echo "replaceWithinString: $1, $2, $3" >&2 |
136 | #echo ${1//$2/$3} # causes error in BSD even though not used | 165 | #echo ${1//$2/$3} # causes error in BSD even though not used |
@@ -182,7 +211,7 @@ convertIcon(){ | |||
182 | if [ -f "${entry_icon}" ]; then | 211 | if [ -f "${entry_icon}" ]; then |
183 | : echo "File exists. To overwrite, type: convert \"$1\" \"$entry_icon\"" >&2 | 212 | : echo "File exists. To overwrite, type: convert \"$1\" \"$entry_icon\"" >&2 |
184 | else | 213 | else |
185 | if command -v convert &> /dev/null; then | 214 | if which convert &> /dev/null; then |
186 | convert "$1" "$entry_icon" | 215 | convert "$1" "$entry_icon" |
187 | # echo convert "$1" , "$entry_icon" >> $ICONMAPPING | 216 | # echo convert "$1" , "$entry_icon" >> $ICONMAPPING |
188 | else | 217 | else |
@@ -1349,7 +1378,7 @@ fi | |||
1349 | # prefix | 1378 | # prefix |
1350 | PREFIX="${PREFIX:=@PREFIX@}" | 1379 | PREFIX="${PREFIX:=@PREFIX@}" |
1351 | if [ -z "${PREFIX}" -o ! -d "${PREFIX}" ]; then | 1380 | if [ -z "${PREFIX}" -o ! -d "${PREFIX}" ]; then |
1352 | PREFIX=`command -v fluxbox | sed 's,/bin/fluxbox$,,'` | 1381 | PREFIX=`which fluxbox | sed 's,/bin/fluxbox$,,'` |
1353 | fi | 1382 | fi |
1354 | 1383 | ||
1355 | 1384 | ||