[
https://issues.apache.org/jira/browse/EXEC-83?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13949133#comment-13949133
]
Benjamin Mesing commented on EXEC-83:
-------------------------------------
Hello,
I am encountering the same issue and it is not specific to bash but to Linux in
general.
Example
{code}
// code does not work: tries to open: text.txt" (note the extra double space at
the end)
// ps shows: gvim "/examplepath/with space/test.txt" (the double quotes are
wrong here!)
CommandLine cl = new CommandLine("gvim");
cl.addArgument("/examplepath/with space/test.txt");
Executor executor = new DefaultExecutor();
executor.execute(cl);
// code does not work (same as above)
CommandLine cl = new CommandLine.parse("gvim \"/examplepath/with
space/test.txt\"");
Executor executor = new DefaultExecutor();
executor.execute(cl);
// ok, opens the right file
// ps shows: gvim /examplepath/with space/test.txt
CommandLine cl = new CommandLine("gvim");
cl.addArgument("/examplepath/with space/test.txt", false);
Executor executor = new DefaultExecutor();
executor.execute(cl);
{code}
On Windows the same code (i.e. using parse or add argument) does work.
I am using version 1.2.
I would vote to raise severity of the issue.
Best regards
Ben
> Arguments with spaces lead to quotes in arguments in bash
> ---------------------------------------------------------
>
> Key: EXEC-83
> URL: https://issues.apache.org/jira/browse/EXEC-83
> Project: Commons Exec
> Issue Type: Bug
> Affects Versions: 1.2
> Environment: Java 7 & OSX
> Reporter: Kevin Brown
> Priority: Minor
>
> If I run my script directly from a bash prompt I see a different behavior
> than if I launch with commons-exec. This may be the nature of the beast
> (java Runtime-exec interacting with bash), but leads me to have to rewrite
> scripts to remove extraneous quotes.
> Here is my script:
> $ cat ./foo.sh
> #!/bin/bash
> echo "$@"
> case I: commons-exec with no spaces ==> arguments do NOT have quotes when in
> bash script
> cmdLine=[/opt/bmam/bin/avidcommand/write_xmp_remote.sh, 70059021,
> RAW-one_two_three, http://foo.com]
> output (of $@):
> 70059021 RAW-one_two_three http://foo.com
> case II: commons-exec with spaces ==> arguments have quotes when in bash
> script
> cmdLine=[/opt/bin/foo.sh, 70058269, "AIR-one two three", http://foo.com]
> output (of $@):
> 70058269 "AIR-one two three" http://foo.com
> case III: execute directly from bash ==> arguments do NOT have quotes when in
> bash script
> $./foo.sh 70058891 "one two three" http://foo.com
> output (of $@):
> 70058891 one two three http://foo.com
--
This message was sent by Atlassian JIRA
(v6.2#6252)