Skip to content

Commit 781e82c

Browse files
committed
tests: only override sort & find if there are usable ones in /usr/bin/
The idea is to allow running the test suite on MinGit with BusyBox installed in /mingw64/bin/sh.exe. In that case, we will want to exclude sort & find (and other Unix utilities) from being bundled. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 52ec197 commit 781e82c

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

git-sh-setup.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,20 @@ create_virtual_base() {
332332
# Platform specific tweaks to work around some commands
333333
case $(uname -s) in
334334
*MINGW*)
335-
# Windows has its own (incompatible) sort and find
336-
sort () {
337-
/usr/bin/sort "$@"
338-
}
339-
find () {
340-
/usr/bin/find "$@"
341-
}
335+
if test -x /usr/bin/sort
336+
then
337+
# Windows has its own (incompatible) sort; override
338+
sort () {
339+
/usr/bin/sort "$@"
340+
}
341+
fi
342+
if test -x /usr/bin/find
343+
then
344+
# Windows has its own (incompatible) find; override
345+
find () {
346+
/usr/bin/find "$@"
347+
}
348+
fi
342349
# git sees Windows-style pwd
343350
pwd () {
344351
builtin pwd -W

t/test-lib.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,13 +1224,20 @@ yes () {
12241224
uname_s=$(uname -s)
12251225
case $uname_s in
12261226
*MINGW*)
1227-
# Windows has its own (incompatible) sort and find
1228-
sort () {
1229-
/usr/bin/sort "$@"
1230-
}
1231-
find () {
1232-
/usr/bin/find "$@"
1233-
}
1227+
if test -x /usr/bin/sort
1228+
then
1229+
# Windows has its own (incompatible) sort; override
1230+
sort () {
1231+
/usr/bin/sort "$@"
1232+
}
1233+
fi
1234+
if test -x /usr/bin/find
1235+
then
1236+
# Windows has its own (incompatible) find; override
1237+
find () {
1238+
/usr/bin/find "$@"
1239+
}
1240+
fi
12341241
# git sees Windows-style pwd
12351242
pwd () {
12361243
builtin pwd -W

0 commit comments

Comments
 (0)