[
https://issues.apache.org/jira/browse/EXEC-93?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14933714#comment-14933714
]
Sebb commented on EXEC-93:
--------------------------
Regarding Michael's comment about {{addArgument("--datadir='/tmp/dir with
space'")}} not being handled correctly:
I think that is a different issue, though again related to specific OS syntax.
Again, I don't think it's possible in general to do the required quoting
without having detailed knowledge of the shell syntax.
There are various addArgument() methods with different parameters.
Some allow argument quoting to be disabled.
This should be chosen if the automatic quoting does not work properly.
In which case it is up to the user to quote the parameter themselves.
It's perhaps unfortunate that the default is to perform automatic quoting,
because in general this is not possible.
The example of the --datadir parameter is a case in point.
{{--param=param with space}} probably needs to be quoted as {{--param='param
with space'}} on Unix
However {{param=param with space}} probably needs to be quoted as
{{"param=param with space"}} on Unix
How can one tell the difference unless one knows the command-line syntax?
Also, what is the quoting guarding against?
If the parameters are being passed to the shell, then they probably do need to
be suitably quoted, because the shell does command line expansion.
However most Unix programs do not do any command line manipulation; they rely
on the shell to do it for them.
So there should be no need to quote arguments that are passed directly to
non-shell programs.
> 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)