Skip to content

Commit a19f790

Browse files
authored
Merge pull request #820 from hakkiplaten/patch-2
Convert has_lib.sh to sh so it also works on BSD OSes
2 parents fe84b6c + 038daf6 commit a19f790

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

util/has_lib.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
has_ldconfig() {
44
hash ldconfig 2>/dev/null
55
}
66

77
has_system_lib() {
8-
local regex="lib$1.+(so|dylib)"
8+
regex="lib$1.+(so|dylib)"
99

1010
# Add /sbin to path as ldconfig is located there on some systems - e.g. Debian
1111
# (and it still can be used by unprivileged users):
1212
PATH="$PATH:/sbin"
1313
export PATH
14-
# Try using ldconfig on linux systems
15-
if $(has_ldconfig); then
14+
15+
# Try using ldconfig on Linux systems
16+
if has_ldconfig; then
1617
for _ in $(ldconfig -p 2>/dev/null | grep -E "$regex"); do
1718
return 0
1819
done
1920
fi
2021

2122
# Try just checking common library locations
2223
for dir in /lib /usr/lib /usr/local/lib /opt/local/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu; do
23-
test -d $dir && ls $dir | grep -E "$regex" && return 0
24+
test -d "$dir" && echo "$dir"/* | grep -E "$regex" && return 0
2425
done
2526

2627
return 1

0 commit comments

Comments
 (0)