You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sk...@free.fr on 2009/02/17 04:08:10 UTC

[commons-exec] API discussion: Quoting of arguments: why is it enabled by default?

I did not notice all commons-* were using the same mailing-list, so here is the
correct subject along with the original message

Sorry for the inconvenience,
sami

----- Forwarded message from Ralph Goers <ra...@dslextreme.com> -----
    Date: Mon, 16 Feb 2009 18:22:20 -0800
    From: Ralph Goers <ra...@dslextreme.com>
Reply-To: Commons Developers List <de...@commons.apache.org>
 Subject: Re: API discussion: Quoting of arguments: why is it enabled by
default?
      To: Commons Developers List <de...@commons.apache.org>

Can you change your subject to start with [XYZ] and replace XYZ with
the Commons project your question pertains to?

Thanks,
Ralph

On Feb 16, 2009, at 2:27 PM, skoobi@free.fr wrote:

> Hi,
>
> I am wondering why the quoting of arguments (if they contain spaces)
> is enabled
> by default.
>
> This is certainly not the behaviour I was expecting while using the
> API, as
> passing a filename as an argument will just fail if it is surrounded
> with
> quotes.
>
> regards,
> sami dalouche
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


----- End forwarded message -----



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [commons-exec] API discussion: Quoting of arguments: why is it enabled by default?

Posted by sk...@free.fr.
Hi,

thanks for your answer.

However, I'm not sure I understand the exact intent of the quoting. what problem
is it supposed to solve ?

sami

Quoting Siegfried Goeschl <si...@it20one.at>:

> Hi Sami,
>
> looking though the SVN history
>
> +) quoting of the arguments was always turned on
> +) I added the flag were you could suppress quoting
>
> Not sure what the effects are when I disable the quoting when calling
> executables and/or shell scripts ...
>
> Cheers,
>
> Siegfried Goeschl
>
> Siegfried Goeschl wrote:
> > Hi Sami,
> >
> > I see your point ...
> >
> > +) quoting is expected when passing a command line string which need
> parsing
> > +) quoting comes as surprise when using an array of arguments
> >
> > I have a look at the code ...
> >
> > Cheers,
> >
> > Siegfried Goeschl
> >
> >
> > skoobi@free.fr wrote:
> >
> >> Basically, my use case is to execute (on linux) :
> >>  ffmpeg -i /tmp/myfile
> >>   and in case of a space
> >>  ffmpeg -i "/tmp/my file with spaces"
> >>
> >> Let's say I called ffmpeg using Runtime.exec, the command array I would
> pass
> >> would be :
> >>
> >> {"ffmpeg", "-i", "/tmp/my file with spaces"}
> >>
> >> now, using commons exec, I would intuitively do :
> >>
> >> - new CommandLine("ffmpeg").addArgument("-i").addArgument("/tmp/my file
> with
> >> spaces")
> >>
> >> However, this would be the equivalent of the following command array :
> >> {"ffmpeg", "-i", "\"/tmp/my file with spaces\""}
> >>
> >> so, ffmpeg does not get /tmp/my file with spaces but gets "/tmp/my file
> with
> >> spaces", and does not find the file as it does not interpret quotes, only
> the
> >> shell does.
> >>
> >> However, if I
> >> new CommandLine("ffmpeg").addArgument("-i", false).addArgument("/tmp/my
> file
> >> with spaces", false)
> >> => everything works fine
> >>
> >> regards,
> >> Sami Dalouche
> >>
> >> Quoting Siegfried Goeschl <si...@it20one.at>:
> >>
> >>
> >>
> >>> Hi Sami,
> >>>
> >>> not sure that I understand the problem
> >>>
> >>> +) commons-exec is basically Ant code so it does the all the things Ant
> >>> is doing, e.g. hard-to-understand quoting
> >>> +) inside the code it is pretty hard to distinguish between a file name
> >>> and a funny argument string (both containing spaces) so we assume that
> >>> this is a file name which need quoting
> >>> +) since quoting seems to be the #1 topic - please check
> >>> http://commons.apache.org/exec/faq.html#complex-quoting
> >>>
> >>> So I suggest
> >>>
> >>> +) have a look if you could solve your problem by avoiding a single
> >>> command line
> >>> +) describe your problems a bit more detailed
> >>>
> >>> Cheers,
> >>>
> >>> Siegfried Goeschl
> >>>
> >>> skoobi@free.fr wrote:
> >>>
> >>>
> >>>> I did not notice all commons-* were using the same mailing-list, so here
> is
> >>>>
> >>>>
> >>> the
> >>>
> >>>
> >>>> correct subject along with the original message
> >>>>
> >>>> Sorry for the inconvenience,
> >>>> sami
> >>>>
> >>>> ----- Forwarded message from Ralph Goers <ra...@dslextreme.com>
> -----
> >>>>     Date: Mon, 16 Feb 2009 18:22:20 -0800
> >>>>     From: Ralph Goers <ra...@dslextreme.com>
> >>>> Reply-To: Commons Developers List <de...@commons.apache.org>
> >>>>  Subject: Re: API discussion: Quoting of arguments: why is it enabled by
> >>>> default?
> >>>>       To: Commons Developers List <de...@commons.apache.org>
> >>>>
> >>>> Can you change your subject to start with [XYZ] and replace XYZ with
> >>>> the Commons project your question pertains to?
> >>>>
> >>>> Thanks,
> >>>> Ralph
> >>>>
> >>>> On Feb 16, 2009, at 2:27 PM, skoobi@free.fr wrote:
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>> Hi,
> >>>>>
> >>>>> I am wondering why the quoting of arguments (if they contain spaces)
> >>>>> is enabled
> >>>>> by default.
> >>>>>
> >>>>> This is certainly not the behaviour I was expecting while using the
> >>>>> API, as
> >>>>> passing a filename as an argument will just fail if it is surrounded
> >>>>> with
> >>>>> quotes.
> >>>>>
> >>>>> regards,
> >>>>> sami dalouche
> >>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> >>>>> For additional commands, e-mail: dev-help@commons.apache.org
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> >>>> For additional commands, e-mail: dev-help@commons.apache.org
> >>>>
> >>>>
> >>>> ----- End forwarded message -----
> >>>>
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> >>>> For additional commands, e-mail: dev-help@commons.apache.org
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> >>> For additional commands, e-mail: dev-help@commons.apache.org
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >>
> >>
> >
> >
>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [commons-exec] API discussion: Quoting of arguments: why is it enabled by default?

Posted by Siegfried Goeschl <si...@it20one.at>.
Hi Sami,

looking though the SVN history

+) quoting of the arguments was always turned on
+) I added the flag were you could suppress quoting

Not sure what the effects are when I disable the quoting when calling
executables and/or shell scripts ...

Cheers,

Siegfried Goeschl

Siegfried Goeschl wrote:
> Hi Sami,
>
> I see your point ...
>
> +) quoting is expected when passing a command line string which need parsing
> +) quoting comes as surprise when using an array of arguments
>
> I have a look at the code ...
>
> Cheers,
>
> Siegfried Goeschl
>
>
> skoobi@free.fr wrote:
>   
>> Basically, my use case is to execute (on linux) :
>>  ffmpeg -i /tmp/myfile
>>   and in case of a space
>>  ffmpeg -i "/tmp/my file with spaces"
>>
>> Let's say I called ffmpeg using Runtime.exec, the command array I would pass
>> would be :
>>
>> {"ffmpeg", "-i", "/tmp/my file with spaces"}
>>
>> now, using commons exec, I would intuitively do :
>>
>> - new CommandLine("ffmpeg").addArgument("-i").addArgument("/tmp/my file with
>> spaces")
>>
>> However, this would be the equivalent of the following command array :
>> {"ffmpeg", "-i", "\"/tmp/my file with spaces\""}
>>
>> so, ffmpeg does not get /tmp/my file with spaces but gets "/tmp/my file with
>> spaces", and does not find the file as it does not interpret quotes, only the
>> shell does.
>>
>> However, if I
>> new CommandLine("ffmpeg").addArgument("-i", false).addArgument("/tmp/my file
>> with spaces", false)
>> => everything works fine
>>
>> regards,
>> Sami Dalouche
>>
>> Quoting Siegfried Goeschl <si...@it20one.at>:
>>
>>   
>>     
>>> Hi Sami,
>>>
>>> not sure that I understand the problem
>>>
>>> +) commons-exec is basically Ant code so it does the all the things Ant
>>> is doing, e.g. hard-to-understand quoting
>>> +) inside the code it is pretty hard to distinguish between a file name
>>> and a funny argument string (both containing spaces) so we assume that
>>> this is a file name which need quoting
>>> +) since quoting seems to be the #1 topic - please check
>>> http://commons.apache.org/exec/faq.html#complex-quoting
>>>
>>> So I suggest
>>>
>>> +) have a look if you could solve your problem by avoiding a single
>>> command line
>>> +) describe your problems a bit more detailed
>>>
>>> Cheers,
>>>
>>> Siegfried Goeschl
>>>
>>> skoobi@free.fr wrote:
>>>     
>>>       
>>>> I did not notice all commons-* were using the same mailing-list, so here is
>>>>       
>>>>         
>>> the
>>>     
>>>       
>>>> correct subject along with the original message
>>>>
>>>> Sorry for the inconvenience,
>>>> sami
>>>>
>>>> ----- Forwarded message from Ralph Goers <ra...@dslextreme.com> -----
>>>>     Date: Mon, 16 Feb 2009 18:22:20 -0800
>>>>     From: Ralph Goers <ra...@dslextreme.com>
>>>> Reply-To: Commons Developers List <de...@commons.apache.org>
>>>>  Subject: Re: API discussion: Quoting of arguments: why is it enabled by
>>>> default?
>>>>       To: Commons Developers List <de...@commons.apache.org>
>>>>
>>>> Can you change your subject to start with [XYZ] and replace XYZ with
>>>> the Commons project your question pertains to?
>>>>
>>>> Thanks,
>>>> Ralph
>>>>
>>>> On Feb 16, 2009, at 2:27 PM, skoobi@free.fr wrote:
>>>>
>>>>
>>>>       
>>>>         
>>>>> Hi,
>>>>>
>>>>> I am wondering why the quoting of arguments (if they contain spaces)
>>>>> is enabled
>>>>> by default.
>>>>>
>>>>> This is certainly not the behaviour I was expecting while using the
>>>>> API, as
>>>>> passing a filename as an argument will just fail if it is surrounded
>>>>> with
>>>>> quotes.
>>>>>
>>>>> regards,
>>>>> sami dalouche
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>>>> For additional commands, e-mail: dev-help@commons.apache.org
>>>>>
>>>>>
>>>>>         
>>>>>           
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>>> For additional commands, e-mail: dev-help@commons.apache.org
>>>>
>>>>
>>>> ----- End forwarded message -----
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>>> For additional commands, e-mail: dev-help@commons.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>       
>>>>         
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: dev-help@commons.apache.org
>>>
>>>
>>>     
>>>       
>>
>>
>>   
>>     
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [commons-exec] API discussion: Quoting of arguments: why is it enabled by default?

Posted by Siegfried Goeschl <si...@it20one.at>.
Hi Sami,

I see your point ...

+) quoting is expected when passing a command line string which need parsing
+) quoting comes as surprise when using an array of arguments

I have a look at the code ...

Cheers,

Siegfried Goeschl


skoobi@free.fr wrote:
> Basically, my use case is to execute (on linux) :
>  ffmpeg -i /tmp/myfile
>   and in case of a space
>  ffmpeg -i "/tmp/my file with spaces"
>
> Let's say I called ffmpeg using Runtime.exec, the command array I would pass
> would be :
>
> {"ffmpeg", "-i", "/tmp/my file with spaces"}
>
> now, using commons exec, I would intuitively do :
>
> - new CommandLine("ffmpeg").addArgument("-i").addArgument("/tmp/my file with
> spaces")
>
> However, this would be the equivalent of the following command array :
> {"ffmpeg", "-i", "\"/tmp/my file with spaces\""}
>
> so, ffmpeg does not get /tmp/my file with spaces but gets "/tmp/my file with
> spaces", and does not find the file as it does not interpret quotes, only the
> shell does.
>
> However, if I
> new CommandLine("ffmpeg").addArgument("-i", false).addArgument("/tmp/my file
> with spaces", false)
> => everything works fine
>
> regards,
> Sami Dalouche
>
> Quoting Siegfried Goeschl <si...@it20one.at>:
>
>   
>> Hi Sami,
>>
>> not sure that I understand the problem
>>
>> +) commons-exec is basically Ant code so it does the all the things Ant
>> is doing, e.g. hard-to-understand quoting
>> +) inside the code it is pretty hard to distinguish between a file name
>> and a funny argument string (both containing spaces) so we assume that
>> this is a file name which need quoting
>> +) since quoting seems to be the #1 topic - please check
>> http://commons.apache.org/exec/faq.html#complex-quoting
>>
>> So I suggest
>>
>> +) have a look if you could solve your problem by avoiding a single
>> command line
>> +) describe your problems a bit more detailed
>>
>> Cheers,
>>
>> Siegfried Goeschl
>>
>> skoobi@free.fr wrote:
>>     
>>> I did not notice all commons-* were using the same mailing-list, so here is
>>>       
>> the
>>     
>>> correct subject along with the original message
>>>
>>> Sorry for the inconvenience,
>>> sami
>>>
>>> ----- Forwarded message from Ralph Goers <ra...@dslextreme.com> -----
>>>     Date: Mon, 16 Feb 2009 18:22:20 -0800
>>>     From: Ralph Goers <ra...@dslextreme.com>
>>> Reply-To: Commons Developers List <de...@commons.apache.org>
>>>  Subject: Re: API discussion: Quoting of arguments: why is it enabled by
>>> default?
>>>       To: Commons Developers List <de...@commons.apache.org>
>>>
>>> Can you change your subject to start with [XYZ] and replace XYZ with
>>> the Commons project your question pertains to?
>>>
>>> Thanks,
>>> Ralph
>>>
>>> On Feb 16, 2009, at 2:27 PM, skoobi@free.fr wrote:
>>>
>>>
>>>       
>>>> Hi,
>>>>
>>>> I am wondering why the quoting of arguments (if they contain spaces)
>>>> is enabled
>>>> by default.
>>>>
>>>> This is certainly not the behaviour I was expecting while using the
>>>> API, as
>>>> passing a filename as an argument will just fail if it is surrounded
>>>> with
>>>> quotes.
>>>>
>>>> regards,
>>>> sami dalouche
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>>> For additional commands, e-mail: dev-help@commons.apache.org
>>>>
>>>>
>>>>         
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: dev-help@commons.apache.org
>>>
>>>
>>> ----- End forwarded message -----
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: dev-help@commons.apache.org
>>>
>>>
>>>
>>>
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>>     
>
>
>
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [commons-exec] API discussion: Quoting of arguments: why is it enabled by default?

Posted by sk...@free.fr.
Basically, my use case is to execute (on linux) :
 ffmpeg -i /tmp/myfile
  and in case of a space
 ffmpeg -i "/tmp/my file with spaces"

Let's say I called ffmpeg using Runtime.exec, the command array I would pass
would be :

{"ffmpeg", "-i", "/tmp/my file with spaces"}

now, using commons exec, I would intuitively do :

- new CommandLine("ffmpeg").addArgument("-i").addArgument("/tmp/my file with
spaces")

However, this would be the equivalent of the following command array :
{"ffmpeg", "-i", "\"/tmp/my file with spaces\""}

so, ffmpeg does not get /tmp/my file with spaces but gets "/tmp/my file with
spaces", and does not find the file as it does not interpret quotes, only the
shell does.

However, if I
new CommandLine("ffmpeg").addArgument("-i", false).addArgument("/tmp/my file
with spaces", false)
=> everything works fine

regards,
Sami Dalouche

Quoting Siegfried Goeschl <si...@it20one.at>:

> Hi Sami,
>
> not sure that I understand the problem
>
> +) commons-exec is basically Ant code so it does the all the things Ant
> is doing, e.g. hard-to-understand quoting
> +) inside the code it is pretty hard to distinguish between a file name
> and a funny argument string (both containing spaces) so we assume that
> this is a file name which need quoting
> +) since quoting seems to be the #1 topic - please check
> http://commons.apache.org/exec/faq.html#complex-quoting
>
> So I suggest
>
> +) have a look if you could solve your problem by avoiding a single
> command line
> +) describe your problems a bit more detailed
>
> Cheers,
>
> Siegfried Goeschl
>
> skoobi@free.fr wrote:
> > I did not notice all commons-* were using the same mailing-list, so here is
> the
> > correct subject along with the original message
> >
> > Sorry for the inconvenience,
> > sami
> >
> > ----- Forwarded message from Ralph Goers <ra...@dslextreme.com> -----
> >     Date: Mon, 16 Feb 2009 18:22:20 -0800
> >     From: Ralph Goers <ra...@dslextreme.com>
> > Reply-To: Commons Developers List <de...@commons.apache.org>
> >  Subject: Re: API discussion: Quoting of arguments: why is it enabled by
> > default?
> >       To: Commons Developers List <de...@commons.apache.org>
> >
> > Can you change your subject to start with [XYZ] and replace XYZ with
> > the Commons project your question pertains to?
> >
> > Thanks,
> > Ralph
> >
> > On Feb 16, 2009, at 2:27 PM, skoobi@free.fr wrote:
> >
> >
> >> Hi,
> >>
> >> I am wondering why the quoting of arguments (if they contain spaces)
> >> is enabled
> >> by default.
> >>
> >> This is certainly not the behaviour I was expecting while using the
> >> API, as
> >> passing a filename as an argument will just fail if it is surrounded
> >> with
> >> quotes.
> >>
> >> regards,
> >> sami dalouche
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> >> For additional commands, e-mail: dev-help@commons.apache.org
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
> > ----- End forwarded message -----
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [commons-exec] API discussion: Quoting of arguments: why is it enabled by default?

Posted by Siegfried Goeschl <si...@it20one.at>.
Hi Sami,

not sure that I understand the problem

+) commons-exec is basically Ant code so it does the all the things Ant
is doing, e.g. hard-to-understand quoting
+) inside the code it is pretty hard to distinguish between a file name
and a funny argument string (both containing spaces) so we assume that
this is a file name which need quoting
+) since quoting seems to be the #1 topic - please check
http://commons.apache.org/exec/faq.html#complex-quoting

So I suggest

+) have a look if you could solve your problem by avoiding a single
command line
+) describe your problems a bit more detailed

Cheers,

Siegfried Goeschl

skoobi@free.fr wrote:
> I did not notice all commons-* were using the same mailing-list, so here is the
> correct subject along with the original message
>
> Sorry for the inconvenience,
> sami
>
> ----- Forwarded message from Ralph Goers <ra...@dslextreme.com> -----
>     Date: Mon, 16 Feb 2009 18:22:20 -0800
>     From: Ralph Goers <ra...@dslextreme.com>
> Reply-To: Commons Developers List <de...@commons.apache.org>
>  Subject: Re: API discussion: Quoting of arguments: why is it enabled by
> default?
>       To: Commons Developers List <de...@commons.apache.org>
>
> Can you change your subject to start with [XYZ] and replace XYZ with
> the Commons project your question pertains to?
>
> Thanks,
> Ralph
>
> On Feb 16, 2009, at 2:27 PM, skoobi@free.fr wrote:
>
>   
>> Hi,
>>
>> I am wondering why the quoting of arguments (if they contain spaces)
>> is enabled
>> by default.
>>
>> This is certainly not the behaviour I was expecting while using the
>> API, as
>> passing a filename as an argument will just fail if it is surrounded
>> with
>> quotes.
>>
>> regards,
>> sami dalouche
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
> ----- End forwarded message -----
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org