[
https://issues.apache.org/jira/browse/EXEC-93?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14935516#comment-14935516
]
Sebb commented on EXEC-93:
--------------------------
I still don't see this as a valid addition to EXEC.
It would need to know lots about the environment in which it is being used.
It seems to me that the application that uses the Exec code is best placed to
know about and handle the quoting.
Besides, if the script is written to expect spaces etc in parameters I suspect
that using unquoted parameters will work fine.
Try the following shell script:
{code:title=parms.sh|borderStyle=solid}
echo Count=$#
while [ $# -gt 0 ]
do
echo "]$1[" # ][ are used to show the ends of the params; note the
enclosing quotes
shift
done
{code}
with the following code:
{code:title=Exec.java|borderStyle=solid}
CommandLine cl = new CommandLine("./parms.sh");
cl.addArgument("a b c d", false);
cl.addArgument("*", false);
cl.addArgument("--datadir='/tmp/dir with space'", false);
DefaultExecutor executor = new DefaultExecutor();
int exitValue = executor.execute(cl);
System.out.println("Status = " +exitValue);
{code}
When I run this with Exec 1.3, I get:
{code}
Count=3
]a b c d[
]*[
]--datadir='/tmp/dir with space'[
Status = 0
{code}
> Handling of escaped values by StringUtils
> -----------------------------------------
>
> Key: EXEC-93
> URL: https://issues.apache.org/jira/browse/EXEC-93
> Project: Commons Exec
> Issue Type: Bug
> Affects Versions: 1.3, 1.4
> Reporter: Viktor Sadovnikov
> Fix For: 1.4
>
> Attachments: EXEC-93.patch
>
>
> An arguments can contain an environment variable value. For example, in
> command {{cd /tmp && STORAGE_DIR=/tmp resolve.sh}} {{STORAGE_DIR=/tmp}} is an
> argument, which is used by {{resolve.sh}}.
> However values of the variables can be more complicated and can contain
> escaped quotes. Current implementation of
> {{StringUtils#quoteArgument(String)}} does not handle these values correctly.
> Attached patch contains fix for this problem and unit tests to demonstrate
> the problem and the fix
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)