Skip to content

Commit 354dca3

Browse files
committed
Make bootstrap.sh /bin/sh friendly
1 parent ba3abbd commit 354dca3

File tree

1 file changed

+40
-36
lines changed

1 file changed

+40
-36
lines changed

bootstrap.sh

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@
33
# Written and placed in public domain by Jeffrey Walton
44
# Autotools sucks. My condolences you have to work with it.
55

6-
if ! command -v aclocal &>/dev/null; then
6+
if ! command -v aclocal >/dev/null 2>&1; then
77
echo "aclocal not found. Bootstrap will probably fail"
88
fi
99

10-
if ! command -v automake &>/dev/null; then
10+
if ! command -v automake >/dev/null 2>&1; then
1111
echo "automake not found. Bootstrap will probably fail"
1212
fi
1313

14-
if ! command -v autoupdate &>/dev/null; then
14+
if ! command -v autoupdate >/dev/null 2>&1; then
1515
echo "autoupdate not found. Bootstrap will probably fail"
1616
fi
1717

18-
if ! command -v autoconf &>/dev/null; then
18+
if ! command -v autoconf >/dev/null 2>&1; then
1919
echo "autoconf not found. Bootstrap will probably fail"
2020
fi
2121

22-
if ! command -v autoreconf &>/dev/null; then
22+
if ! command -v autoreconf >/dev/null 2>&1; then
2323
echo "autoreconf not found. Bootstrap will probably fail"
2424
fi
2525

26-
if ! command -v file &>/dev/null; then
26+
if ! command -v file >/dev/null 2>&1; then
2727
echo "file not found. Bootstrap will probably fail"
2828
fi
2929

30-
if ! command -v wget &>/dev/null; then
31-
if ! command -v curl &>/dev/null; then
30+
if ! command -v wget >/dev/null 2>&1; then
31+
if ! command -v curl >/dev/null 2>&1; then
3232
echo "wget and curl not found. Updates will probably fail"
3333
fi
3434
fi
@@ -41,27 +41,27 @@ SED=sed
4141
AWK=awk
4242

4343
# Fixup, Solaris and friends
44-
if [[ -d /usr/xpg4/bin ]]; then
44+
if [ -d /usr/xpg4/bin ]; then
4545
SED=/usr/xpg4/bin/sed
4646
AWK=/usr/xpg4/bin/awk
4747
GREP=/usr/xpg4/bin/grep
48-
elif [[ -d /usr/bin/posix ]]; then
48+
elif [ -d /usr/bin/posix ]; then
4949
SED=/usr/bin/posix/sed
5050
AWK=/usr/bin/posix/awk
5151
GREP=/usr/bin/posix/grep
5252
fi
5353

54-
if command -v wget &>/dev/null; then
54+
if command -v wget >/dev/null 2>&1; then
5555
FETCH_CMD="wget -q -O"
56-
elif command -v curl &>/dev/null; then
56+
elif command -v curl >/dev/null 2>&1; then
5757
FETCH_CMD="curl -L -s -o"
5858
else
59-
FETCH_CMD="foobar"
59+
FETCH_CMD="curl-and-wget-not-found"
6060
fi
6161

6262
# Fixup for sed and "illegal byte sequence"
63-
IS_DARWIN=$(uname -s 2>/dev/null | "$GREP" -i -c darwin)
64-
if [[ "$IS_DARWIN" -ne 0 ]]; then
63+
IS_DARWIN=`uname -s 2>&1 | "$GREP" -i -c darwin`
64+
if [ "$IS_DARWIN" -ne 0 ]; then
6565
LC_ALL=C; export LC_ALL
6666
fi
6767

@@ -75,30 +75,30 @@ fi
7575
mkdir -p m4 build-aux
7676

7777
echo "Running aclocal"
78-
if ! aclocal &>/dev/null; then
78+
if ! aclocal >/dev/null 2>&1; then
7979
echo "aclocal failed."
8080
exit 1
8181
fi
8282

8383
echo "Running autoupdate"
84-
if ! autoupdate &>/dev/null; then
84+
if ! autoupdate >/dev/null 2>&1; then
8585
echo "autoupdate failed."
8686
exit 1
8787
fi
8888

8989
# Run autoreconf twice on failure. Also see
9090
# https://github.com/tracebox/tracebox/issues/57
9191
echo "Running autoreconf"
92-
if ! autoreconf --force --install &>/dev/null; then
92+
if ! autoreconf --force --install >/dev/null 2>&1; then
9393
echo "autoreconf failed, running again."
94-
if ! autoreconf --force --install; then
94+
if ! autoreconf --force --install >/dev/null 2>&1; then
9595
echo "autoreconf failed, again."
9696
exit 1
9797
fi
9898
fi
9999

100100
# Create the configure script
101-
if ! autoconf; then
101+
if ! autoconf >/dev/null 2>&1; then
102102
echo "autoconf failed."
103103
exit 1
104104
fi
@@ -109,29 +109,33 @@ fi
109109
# https://www.gnu.org/software/gettext/manual/html_node/config_002eguess.html
110110

111111
echo "Updating config.sub"
112-
${FETCH_CMD} config.sub.new 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub'
112+
if ${FETCH_CMD} config.sub.new \
113+
'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub' >/dev/null 2>&1; then
113114

114-
# Solaris removes +w, can't overwrite
115-
chmod +w build-aux/config.sub
116-
mv config.sub.new build-aux/config.sub
117-
chmod +x build-aux/config.sub
115+
# Solaris removes +w, can't overwrite
116+
chmod +w build-aux/config.sub
117+
mv config.sub.new build-aux/config.sub
118+
chmod +x build-aux/config.sub
118119

119-
if [[ "$IS_DARWIN" -ne 0 ]] && [[ -n $(command -v xattr 2>/dev/null) ]]; then
120-
echo "Removing config.sub quarantine"
121-
xattr -d "com.apple.quarantine" build-aux/config.sub &>/dev/null
120+
if [ "$IS_DARWIN" -ne 0 ] && [ command -v xattr >/dev/null 2>&1 ]; then
121+
echo "Removing config.sub quarantine"
122+
xattr -d "com.apple.quarantine" build-aux/config.sub >/dev/null 2>&1
123+
fi
122124
fi
123125

124126
echo "Updating config.guess"
125-
${FETCH_CMD} config.guess.new 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess'
127+
if ${FETCH_CMD} config.guess.new \
128+
'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess' >/dev/null 2>&1; then
126129

127-
# Solaris removes +w, can't overwrite
128-
chmod +w build-aux/config.guess
129-
mv config.guess.new build-aux/config.guess
130-
chmod +x build-aux/config.guess
130+
# Solaris removes +w, can't overwrite
131+
chmod +w build-aux/config.guess
132+
mv config.guess.new build-aux/config.guess
133+
chmod +x build-aux/config.guess
131134

132-
if [[ "$IS_DARWIN" -ne 0 ]] && [[ -n $(command -v xattr 2>/dev/null) ]]; then
133-
echo "Removing config.guess quarantine"
134-
xattr -d "com.apple.quarantine" build-aux/config.guess &>/dev/null
135+
if [ "$IS_DARWIN" -ne 0 ] && [ command -v xattr >/dev/null 2>&1 ]; then
136+
echo "Removing config.guess quarantine"
137+
xattr -d "com.apple.quarantine" build-aux/config.guess >/dev/null 2>&1
138+
fi
135139
fi
136140

137141
#############################################################################

0 commit comments

Comments
 (0)