EnvironmentCommandlet can log warnings into the middle of environment variables #531
Labels
bug
Something isn't working
CLI
IDEasy command-line-interface (parsing args, etc.)
environment
EnvironmentCommandlet, env variables, path, etc.
logging
Milestone
Expected behavior
As a IDEasy user, I want to setup my project environment in any shell anywhere with just the command
ide
so that I can start working seamlessly from there.Actual behavior
Setting up the environment variables with
ide
commandlet can cause errors and even potentially security risks.If variables cannot be evaluated, that should normally be logged as warning to notify the user about a problem.
However, the problem with
EnvironmentCommandlet
(ide env
) is that here we are using the "log" as an "API" to the shell (bash or CMD) and send some kind of "code for execution".Now, if some log message like
Undefined variable ${UNDEFINED} in 'SOME'
gets logged into this "code", that breaks the "API".So most likely we have to control the log for this commandlet like we do in
CompleteCommandlet
.Steps to reproduce (bug)
FOO=${BAR} ${SOME} ${UNDEFINED}
to youride.properties
ide
command in that project.I then get errors like this in bash:
Comments/Hints:
See
IDEasy/cli/src/main/java/com/devonfw/tools/ide/commandlet/CompleteCommandlet.java
Line 55 in 752f41e
In EnvironmentCommandletTest we also have a lot of redundancy now for windows and non-windows case in case of info-logging and also I had to comment out the assertion method like this:
log().hasEntries/*WithNothingElseInBetween*/(...)
.To avoid the redundancies, we should manually build the expected
VariableLine
instances and then have an advanced assertion method that can take flags likeboolean quoteValue
andboolean omitExport
.Affected version:
The text was updated successfully, but these errors were encountered: