8258925: configure script failed on WSL

Reviewed-by: dholmes, erikj
This commit is contained in:
Yasumasa Suenaga 2021-01-11 23:13:52 +00:00
parent cd73939b79
commit 712ea25057

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# #
# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
@ -145,11 +145,14 @@ function import_path() {
fi fi
if [[ "$path" != "" ]]; then if [[ "$path" != "" ]]; then
# Store current unix path
unixpath="$path"
# Now turn it into a windows path # Now turn it into a windows path
winpath="$($PATHTOOL -w "$path" 2>/dev/null)" winpath="$($PATHTOOL -w "$path" 2>/dev/null)"
# If it fails, try again with an added .exe (needed on WSL) # If it fails, try again with an added .exe (needed on WSL)
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
winpath="$($PATHTOOL -w "$path.exe" 2>/dev/null)" unixpath="$unixpath.exe"
winpath="$($PATHTOOL -w "$unixpath" 2>/dev/null)"
fi fi
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
if [[ ! "$winpath" =~ ^"$ENVROOT"\\.*$ ]] ; then if [[ ! "$winpath" =~ ^"$ENVROOT"\\.*$ ]] ; then
@ -159,11 +162,11 @@ function import_path() {
# This monster of a command uses the %~s support from cmd.exe to # This monster of a command uses the %~s support from cmd.exe to
# reliably convert to short paths on all winenvs. # reliably convert to short paths on all winenvs.
shortpath="$($CMD /q /c for %I in \( "$winpath" \) do echo %~sI 2>/dev/null | tr -d \\n\\r)" shortpath="$($CMD /q /c for %I in \( "$winpath" \) do echo %~sI 2>/dev/null | tr -d \\n\\r)"
path="$($PATHTOOL -u "$shortpath")" unixpath="$($PATHTOOL -u "$shortpath")"
# Path is now unix style, based on short name # unixpath is based on short name
fi fi
# Make it lower case # Make it lower case
path="$(echo "$path" | tr [:upper:] [:lower:])" path="$(echo "$unixpath" | tr [:upper:] [:lower:])"
fi fi
else else
# On WSL1, PATHTOOL will fail for files in envroot. If the unix path # On WSL1, PATHTOOL will fail for files in envroot. If the unix path