Skip to content

Commit 7d5f463

Browse files
noloaderdanieleds
authored andcommitted
chore: use 'command -v' and $TMPDIR in configure (notepadqq#910)
* Use 'command -v' and $TMPDIR in configure 'command -v' is Posix, and more robust than 'which'. It also handles environments and aliases correctly. Also see https://stackoverflow.com/q/592620/608639. * Use 'command -v' and $TMPDIR in configure 'command -v' is Posix, and more robust than 'which'. It also handles environments and aliases correctly. Also see https://stackoverflow.com/q/592620/608639.
1 parent ab345d5 commit 7d5f463

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

configure

+11-10
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
# Basic environment variables
55
test -n "$MAKE" || MAKE="make"
66
test -n "$CXX" || CXX="c++"
7-
test -n "$QTCHOOSER" || QTCHOOSER="$(which qtchooser 2> /dev/null)"
7+
test -n "$QTCHOOSER" || QTCHOOSER="$(command -v qtchooser 2> /dev/null)"
8+
test -n "$TMPDIR" || TMPDIR="$PWD"
89

9-
# Use qtchooser if we have it, otherwise use which
10+
# Use qtchooser if we have it, otherwise use Posix command -v
1011
if test -n "$QTCHOOSER"; then
1112
test -n "$QMAKE" || QMAKE="$QTCHOOSER -run-tool=qmake -qt=5"
1213
test -n "$LRELEASE" || LRELEASE="$QTCHOOSER -run-tool=lrelease -qt=5"
1314
else
14-
test -n "$QMAKE" || QMAKE="$(which qmake-qt5 2>/dev/null || which qmake 2>/dev/null)"
15-
test -n "$LRELEASE" || LRELEASE="$(which lrelease-qt5 2>/dev/null || which lrelease 2>/dev/null)"
15+
test -n "$QMAKE" || QMAKE="$(command -v qmake-qt5 2>/dev/null || command -v qmake 2>/dev/null)"
16+
test -n "$LRELEASE" || LRELEASE="$(command -v lrelease-qt5 2>/dev/null || command -v lrelease 2>/dev/null)"
1617
fi
1718

1819

@@ -68,8 +69,8 @@ EOF
6869
check() {
6970
printf "checking for $1... "
7071
t=$(basename $2)
71-
which $t 2>/dev/null 1>/dev/null
72-
test $(echo $?) -eq 0 && echo "$(which $t)" || errorExit "not found!" $3
72+
command -v $t 2>/dev/null 1>/dev/null
73+
test $(echo $?) -eq 0 && echo "$(command -v $t)" || errorExit "not found!" $3
7374
}
7475

7576

@@ -148,13 +149,13 @@ int main()
148149
}
149150
EOF
150151
printf "checking whether c++ compiler builds test program... "
151-
$CXX -o test test.cpp && echo "ok" || errorExit "error!" 1
152+
$CXX -o "$TMPDIR/test" test.cpp && echo "ok" || errorExit "error!" 1
152153
printf "checking whether c++ compiler supports -std=c++0x... "
153154
rm -f test
154-
$CXX -std=c++0x -o test test.cpp && echo "ok" || errorExit "error!" 1
155+
$CXX -std=c++0x -o "$TMPDIR/test" test.cpp && echo "ok" || errorExit "error!" 1
155156
printf "checking whether compiled test program works... "
156-
./test 2>/dev/null 1>/dev/null && echo "ok" || errorExit "error!" 1
157-
rm -f test test.cpp
157+
"$TMPDIR/test" 2>/dev/null 1>/dev/null && echo "ok" || errorExit "error!" 1
158+
rm -f "$TMPDIR/test" test.cpp
158159

159160
check make "$MAKE" 1
160161
check pkg-config pkg-config 1

0 commit comments

Comments
 (0)