[jboss-jira] [JBoss JIRA] (WFLY-3662) CLI control flow statements not working for commands
Alexey Loubyansky (JIRA)
issues at jboss.org
Tue Jul 29 12:00:34 EDT 2014
[ https://issues.jboss.org/browse/WFLY-3662?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12988728#comment-12988728 ]
Alexey Loubyansky commented on WFLY-3662:
-----------------------------------------
The idea of if-else-end-if and try-catch-finally was that each block of statements was supposed to be transformed into a batch and executed as an atomic operation request depending on the condition. This contract works properly.
Here, you mix commands that can't be a part of a batch (e.g. echo and module) with the operations. The CLI, in the current impl, still goes through the lines in all the blocks and composes batches for all of them. When the CLI is in a batch mode and meets a command which can't be a part of the batch, it executes the command right away. (That's a deliberate decision and is useful for commands like cd, etc.)
So, the CLI composes batches for all the blocks it parses, it doesn't execute any of them until the whole if-else-end-if structure is parsed. Then it evaluates the condition and chooses which batch to execute.
According to the original purpose, this is not a bug. I'd classify it as an enhancement. I agree, it's tempting to assume your use-case should work and it's undoubtedly a useful functionality. I'm gonna look into this.
> CLI control flow statements not working for commands
> ----------------------------------------------------
>
> Key: WFLY-3662
> URL: https://issues.jboss.org/browse/WFLY-3662
> Project: WildFly
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: CLI
> Affects Versions: 8.1.0.Final
> Reporter: Stanley Hillner
> Assignee: Alexey Loubyansky
> Priority: Critical
> Labels: cli, command, command-line, script
>
> The CLI control flows, such as if-then-else, are not working for CLI commands, such as echo or module. Using commands in control flows results in the strange behavior that these commands are executed in each case without respecting to what the if-statement evaluated.
> I am trying to customize a fresh wildfly server with some modules and settings for our development process. I decided to add modules using a CLI script that gets executed by maven, but when the script declares the following the module command in the 'then' block is executed in each case:
> {noformat}
> if (outcome == failed) of /core-service=module-loading:list-resource-loader-paths(module=oracle.jdbcaq)
> module add --name=oracle.jdbcaq ...
> end-if
> ...
> {noformat}
> I've also verified this behavior with another structure that just checks a property and echos something and both echos were executed:
> {noformat}
> /system-property=x:add(value=123)
> if (result == 123) of /system-property=x:read-attribute(name=value)
> echo "If block"
> /system-property=x:read-attribute(name=value)
> else
> echo "Else block"
> /system-property=x:read-attribute(name=value)
> end-if
> {noformat}
> The next thing is that if you just put echos into the if and else blocks, the CLI processor complains about an empty if-block. Try this one:
> {noformat}
> /system-property=x:add(value=123)
> if (result == 123) of /system-property=x:read-attribute(name=value)
> echo "If block"
> else
> echo "Else block"
> end-if
> {noformat}
> This behavior has also been observed by other users (see the forum reference) and for me it is critical to our setup since the only alternative would be copying modules manually to the modules folder. Furthermore, there might be other commands required for us to adapt the standalone configuration that need to be nested in an if-statement.
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
More information about the jboss-jira
mailing list