[jboss-jira] [JBoss JIRA] (WFCORE-3484) Nonintuitive error message when for loop is used inside of if/try/batch constructs

Jean-Francois Denise (JIRA) issues at jboss.org
Tue Jan 2 11:40:00 EST 2018


    [ https://issues.jboss.org/browse/WFCORE-3484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13508456#comment-13508456 ] 

Jean-Francois Denise edited comment on WFCORE-3484 at 1/2/18 11:39 AM:
-----------------------------------------------------------------------

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.: if followed by if, ... The CLI accepts the new redirection silently.

Finally, having an If inside a for is supported. Nesting of the same redirection is not supported, but you can mix redirections. I will update the analysis document, it was not clear.




was (Author: jdenise):
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 at embedded /] if (outcome != success) of /system-property=test:read-resource
> [standalone at embedded /] for propName in :read-children-names(child-type=system-property)
> [standalone at 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 at embedded /] try
> [standalone at embedded /] for propName in :read-children-names(child-type=system-property)
> [standalone at embedded /] echo $propName
> Unrecognized variable propName
> {code}
> The same applies here as for "if" case.
> {code:title=Using for inside batch}
> [standalone at embedded /] batch
> [standalone at 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 at embedded /] for propName in :read-children-names(child-type=system-property)
> [standalone at 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)


More information about the jboss-jira mailing list