gnodet-bot commented on code in PR #13429:
URL: https://github.com/apache/maven/pull/13429#discussion_r4245494765
##########
apache-maven/src/bin/mvn:
##########
@@ -75,6 +75,26 @@ if $cygwin || $mingw ; then
fi
fi
+# A cygpath(1) from an unrelated POSIX emulation layer (e.g. the one shipped in
+# an Anaconda installation) can be found on the PATH first. It re-roots every
+# POSIX path under its own installation prefix, so all converted values point
to
+# non-existing directories and the JVM dies with a bare ClassNotFoundException.
+# cygpath can convert relative paths too, but the current directory is the only
+# path that is known to exist at this point: verify that its Windows form can
be
+# found on disk before trusting any of the later conversions.
+if $cygwin || $mingw ; then
+ _cygpath_bin=`( \unset -f command; \command -v cygpath )` || _cygpath_bin=
+ _probe_win=`cygpath --windows "$PWD"` || _probe_win=
+ if [ -z "$_probe_win" ] || [ ! -d "$_probe_win" ] ; then
+ echo "Warning: the cygpath found on the PATH (\"$_cygpath_bin\") does not
convert paths to" >&2
+ echo "usable Windows paths (\"$PWD\" converts to \"$_probe_win\", which
does not exist)," >&2
+ echo "so Apache Maven cannot convert paths to the Windows format." >&2
+ echo "Some plugins may misbehave when they receive POSIX paths." >&2
Review Comment:
⚠️ **`echo` with Windows paths silently truncates the warning under `dash`.**
The script runs under `#!/bin/sh` — on Debian/Ubuntu (including GitHub
Actions `ubuntu-latest`) `/bin/sh` is `dash`, which interprets backslash
sequences in its built-in `echo`. `$_probe_win` is a Windows path produced by
`cygpath --windows`, so it contains backslashes. When the POSIX path contains a
component starting with `c` (e.g. `cache`, `conda`, `config`, `cmake`), the
Windows form contains `\c` — and dash's `echo` interprets `\c` as **suppress
all further output**, silently truncating the diagnostic. The user sees a
broken, incomplete warning in exactly the scenario this fix is designed to
explain.
Confirmed: `sh -c 'echo "test \\cache\\scratch rest"'` → `test` (stops at
`\c`).
Also confirmed by test run: the assertion `"foreign cygpath: warning shows
the bogus Windows form"` (checking for `"which does not exist"`) fails with the
fix on any system where the temp dir contains `cache/` in its path — the
warning is cut off before that phrase is printed.
Use `printf '%s\n'` instead — `printf` does not interpret backslash
sequences in its arguments:
```suggestion
printf '%s\n' "Warning: the cygpath found on the PATH
(\"$_cygpath_bin\") does not convert paths to" >&2
printf '%s\n' "usable Windows paths (\"$PWD\" converts to
\"$_probe_win\", which does not exist)," >&2
printf '%s\n' "so Apache Maven cannot convert paths to the Windows
format." >&2
printf '%s\n' "Some plugins may misbehave when they receive POSIX
paths." >&2
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]