Skip to content

Commit a1191d1

Browse files
committed
Detect the system on windows instead of reading Windows_NT
ci/lib.sh works out OS only when the caller has not set one: if [[ ! ${OS-} ]]; then OS=$(os); fi Windows predefines OS as Windows_NT in every process environment, so on a windows shell that test always finds a value, os() is never called, and OS stays Windows_NT for the whole build. Every question the build then asks about the system gets an answer it does not understand: which bin scripts to fix up, whether to build packages, what the release archive is called. os() already handles this platform -- `cygwin* | mingw*` answers windows -- it just never gets the chance. Windows_NT is not a name this build knows, so it is not treated as one a caller chose. Measured on a windows shell, sourcing the file three ways: OS unset -> windows (was Windows_NT) OS=Windows_NT -> windows (was Windows_NT) OS=linux -> linux (unchanged) so an explicit choice still wins, which is the point of the check. Nothing changes anywhere else: no other platform sets OS, so the added test is never reached off windows.
1 parent 62284ed commit a1191d1

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

ci/lib.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ if [[ ! ${ARCH-} ]]; then
4949
export ARCH
5050
fi
5151

52-
if [[ ! ${OS-} ]]; then
52+
# Windows predefines OS as Windows_NT for every process, so on a windows shell
53+
# the check below would always find a value and never call os(). That is not a
54+
# name this build knows, so it does not count as one the caller chose.
55+
if [[ ! ${OS-} || ${OS-} == "Windows_NT" ]]; then
5356
OS=$(os)
5457
export OS
5558
fi

0 commit comments

Comments
 (0)