davsclaus opened a new pull request, #29885:
URL: https://github.com/apache/camel/pull/29885

   [CAMEL-26944](https://issues.apache.org/jira/browse/CAMEL-26944)
   
   cmd looks for a bare command name in the current directory before PATH. A 
`findstr.bat`, `powershell.bat`, `curl.bat` or `java.bat` in the directory 
where `camel` runs (for example a cloned project) therefore ran instead of the 
real program. This PR is hardening of the Windows scripts.
   
   ## Changes
   
   - **`camel.bat`** (camel-launcher): the three `findstr` calls (launcher JAR, 
JDK `release` file, `-version` banner) run `%SystemRoot%\System32\findstr.exe`. 
Java discovery already took `java.exe` from PATH only (`%~$PATH:`).
   - **`camelw.cmd`** (the wrapper `camel wrapper` writes into a project):
     - PowerShell and curl run from `%SystemRoot%\System32`, and PowerShell now 
also gets `-NoProfile -NonInteractive`.
     - Without `JAVA_HOME`, `java.exe` comes from PATH only, as in `camel.bat`, 
with a clear error when there is none.
     - Bug fix on the lines this touches: when PowerShell failed and curl then 
succeeded, the wrapper still reported a failed download and exited 1. The curl 
check read `%ERRORLEVEL%` inside the same parenthesized block, which cmd 
expands when it reads the block. It now uses `if not errorlevel 1 goto 
downloaded`.
   
   ## Tests
   
   The tests run on Windows only, in the `windows-validator` job of 
`package-native-validation.yml`.
   
   - `CamelBatDiscoveryTest.runsTheFindstrOfWindowsNotOneInTheCurrentDirectory` 
plants a `findstr.bat` in the working directory and runs `camel.bat` there. It 
covers both version paths: the probe of the `-version` banner, and the 
`release` file.
   - New `CamelwCmdTest` (camel-launcher; it reads `camelw.cmd` from 
camel-jbang-run):
     - java from PATH with a planted `java.bat`;
     - no java at all;
     - a download from a `file:` URL with a planted `powershell.bat` and 
`curl.bat`.
   - `FakeJava.runIn` runs a script in a given working directory.
   - The workflow now also triggers on `camelw.cmd` and runs `CamelwCmdTest`.
   
   I could not run the Windows tests locally (macOS); the module compiles and 
is formatted.
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to