[
https://issues.jboss.org/browse/WFCORE-3484?page=com.atlassian.jira.plugi...
]
Jean-Francois Denise commented on WFCORE-3484:
----------------------------------------------
You have revealed multiple issues there:
1) Variables can't be set and used inside if/try/for.
For example:
if (outcome != success) of /system-property=test:read-resource
set foo=bar
echo $foo
==> You will get an exception. This is the same exception that you are getting when
echoing propName
2) There is no check when a redirection is already active and a new redirection is
used:e.g.: try followed by if, if followed by if, ... The CLI accepts the new redirection
silently.
3) Command name completion is not helpful, although a redirection is active (eg: if),
other redirections are proposed (try, for).
Nonintuitive error message when for loop is used inside of
if/try/batch constructs
----------------------------------------------------------------------------------
Key: WFCORE-3484
URL:
https://issues.jboss.org/browse/WFCORE-3484
Project: WildFly Core
Issue Type: Bug
Components: CLI
Affects Versions: 4.0.0.Alpha5
Reporter: Erich Duda
Assignee: Jean-Francois Denise
CLI enables to use for loop construct for looping over commands or operations. See
WFCORE-3236 for details. Because of design limitations of CLI, using of for loop is not
supported inside of if, try, for and batch constructs. However if you try to do that,
error message is not intuitive in all cases and it is difficult to find out why the code
does not work.
Let's see on real examples.
{code:title=Using for inside if}
[standalone@embedded /] if (outcome != success) of /system-property=test:read-resource
[standalone@embedded /] for propName in :read-children-names(child-type=system-property)
[standalone@embedded /] echo $propName
Unrecognized variable propName
{code}
As you can see in the example, when you write aforementioned commands into the CLI, no
error is thrown until you use the variable declared in the for construct. Additionally the
error message is not saying anything about that using of "for" is not allowed
inside of "if".
{code:title=Using for inside try}
[standalone@embedded /] try
[standalone@embedded /] for propName in :read-children-names(child-type=system-property)
[standalone@embedded /] echo $propName
Unrecognized variable propName
{code}
The same applies here as for "if" case.
{code:title=Using for inside batch}
[standalone@embedded /] batch
[standalone@embedded / #] for propName in
:read-children-names(child-type=system-property)
The command is not available in the current context (e.g. required subsystems or
connection to the controller might be unavailable).
{code}
In the batch case, the error message is better (it says that command is not available),
but still it is not clear why the command is not available.
{code:title=Using for inside for}
[standalone@embedded /] for propName in :read-children-names(child-type=system-property)
[standalone@embedded /] for propName in :read-children-names(child-type=system-property)
for is not allowed while in for block
{code}
Using of nested for loops generates nice error message which clearly explains what is
wrong. All other cases should throw similar error.
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)