+++ This bug was initially created as a clone of Bug #1020066 +++ Description of problem: Executing a script server resource with an argument string including a quoted argument that contains spaces results in the quoted argument being broken out into multiple arguments. For example, "a b" is treated as two arguments. '"a' is the first argument, and 'b"' is the second. Version-Release number of selected component (if applicable): JBoss ON 3.1.2 How reproducible: very Steps to Reproduce: 1. Import script server resource (script example below) 2. Perform "Execute" operation on script server resource 3. Input arguments "a b" 4. Verify output testScript.sh contents: #!/bin/sh echo $# number of arguments > output.txt echo $* >> output.txt echo $@ >> output.txt Actual results: Script reports that 2 arguments have been passed into it. Expected results: Script should report that 1 argument was passed in. Additional info: --- Additional comment from Larry O'Leary on 2013-10-22 18:06:45 EDT --- This issue is a direct result of how the operation's arguments property value is passed along to executeExecutable and then split into multiple arguments using the space: https://git.fedorahosted.org/cgit/rhq/rhq.git/tree/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java#n405 The end result is that: Arg1 "Arg 2" Arg3 Becomes: Arg1 "Arg 2" Arg3 And: Arg1 'Arg 2' Arg3 Becomes: Arg1 'Arg 2' Arg3 And: Arg1 Arg\ 2 Arg3 Becomes: Arg1 Arg\ 2 Arg3 To fix this, a more suitable regular expression and matcher should be applied to handle quoted (double or single) parameters and/or escapes. Possibly a simple command-line parser? The most basic form is to support: Arg1 "Arg 2" Arg3 Arg1 'Arg 2' Arg3 However, from a command-line perspective, the quote may need to be escaped: Arg1 'Arg\'s 2 Value' Arg3 Additionally, the following format seems to be common within the Linux realm: Arg1 Arg\ 2 Arg3
commit 545009710de643a8e21bfad57f4d09915009017a Author: Lukas Krejci <lkrejci> Date: Tue Jan 7 21:43:42 2014 +0100 [BZ 1049608] Support quotes and escapes in script args in script plugin
commit d8e1e71efc8eb3ffcf2729fc4518b37e5cd304e5 Author: Lukas Krejci <lkrejci> Date: Sat Jan 25 00:08:01 2014 +0100 [BZ 1049608] - Changes to arg parsing in script server plugin * we by default keep the broken old behavior (blind split by space) * a boolean plugin prop to switch quoting and escapes on/off * configurable escape char set to \ for all platforms * escaping (when switched on) is POSIX-like: 1) In unquoted text: the escape character preserves the value of any following character 2) In double-quoted text: the escape character escapes " and itself otherwise is both the escape character and the following character are left intact 3) In single-quoted text: no escaping can occur
commit in the release branch: 8058e6ba2
Bulk closing of 4.10 issues. If an issue is not solved for you, please open a new BZ (or clone the existing one) with a version designator of 4.10.