8356820: fixpath should allow + in paths on Windows

Reviewed-by: erikj
This commit is contained in:
Chihiro Ito 2025-05-14 00:25:59 +00:00
parent a96424b24c
commit 0c4bc48928

View File

@ -157,12 +157,12 @@ function import_path() {
if [[ $? -eq 0 && -e "$unixpath" ]]; then if [[ $? -eq 0 && -e "$unixpath" ]]; then
if [[ ! "$winpath" =~ ^"$ENVROOT"\\.*$ ]] ; then if [[ ! "$winpath" =~ ^"$ENVROOT"\\.*$ ]] ; then
# If it is not in envroot, it's a generic windows path # If it is not in envroot, it's a generic windows path
if [[ ! $winpath =~ ^[-_.:~\\a-zA-Z0-9]*$ ]] ; then if [[ ! $winpath =~ ^[-_.:~+\\a-zA-Z0-9]*$ ]] ; then
# Path has forbidden characters, rewrite as short name # Path has forbidden characters, rewrite as short name
# 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)"
if [[ ! $shortpath =~ ^[-_.:~\\a-zA-Z0-9]*$ ]] ; then if [[ ! $shortpath =~ ^[-_.:~+\\a-zA-Z0-9]*$ ]] ; then
if [[ $QUIET != true ]]; then if [[ $QUIET != true ]]; then
echo fixpath: failure: Path "'"$path"'" could not be converted to short path >&2 echo fixpath: failure: Path "'"$path"'" could not be converted to short path >&2
fi fi