You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by "J. Brebec" <je...@gmail.com> on 2020/07/21 08:08:16 UTC

Shell & Quote

Hello,

I have a Karaf shell command which take a String parameters.
How can I call it with a parameters with space and quote ?

this doesn't work (the command is not executed with a error about a non-matched quote)
ns:mycmd "xx n'est pas conforme"

this doesn't work either: the command is executed, but the backlash is seen by my command
ns:mycmd "xx n\'est pas conforme"

I didn't found the right syntax..

thanks!

Jérémie


Re: Shell & Quote

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
For the tracking: https://issues.apache.org/jira/browse/KARAF-6794 <https://issues.apache.org/jira/browse/KARAF-6794>

Regards
JB

> Le 24 juil. 2020 à 07:45, Jean-Baptiste Onofre <jb...@nanthrax.net> a écrit :
> 
> Ah ok I understand now.
> 
> Right now, the only way is to escape space and single quote.
> 
> For instance John\ O\’Deer will end with John O’Deer.
> 
> However, the double quote should do the escape for you, but we have the issue due to Felix Gogo Runtime:
> java.io.EOFException: unexpected EOT looking for matching quote: '
> 
> That’s due to the Felix Gogo runtime update and a change we did there.
> 
> Let me create a Jira and fix that.
> 
> Sorry for the inconvenience.
> 
> Regards
> JB
> 
>> Le 22 juil. 2020 à 13:20, J. Brebec <jeremie.brebec@gmail.com <ma...@gmail.com>> a écrit :
>> 
>> Sorry. My issue is not about double quote or spaces, it's about spaces and single quote (or apostrophe). For example, I have commands which take a query as parameter. I used to write the query with doubles quotes, because there is a lot of spaces. However, I can't use an apostrophe in this kind of query.
>> 
>> If I use your example below, you can see it "looks" like using a quote worked because the syntax error disappears. however it's not, an invalid user has been created with a backslash.
>> 
>> karaf@root()> feature:repo-add mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
>> Adding feature url mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
>> karaf@root()> feature:install karaf-command-example-provider
>> karaf@root()> feature:install karaf-command-example
>> karaf@root()> booking:list
>> ID | Flight | Customer
>> ---+--------+---------
>> karaf@root()> booking:add X1 "John O'Connor"
>> Error executing command: unexpected EOT looking for matching quote: '
>> karaf@root()> booking:add X1 "John O\'Connor"
>> karaf@root()> booking:list
>> ID      | Flight         | Customer
>> --------+----------------+---------
>> 9198438 | John O\'Connor | X1
>> karaf@root()> booking:add X2 John\ O\'Connor
>> karaf@root()> booking:list
>> ID      | Flight         | Customer
>> --------+----------------+---------
>> 6573975 | John O'Connor  | X2
>> 9198438 | John O\'Connor | X1
>> 
>> On 2020/07/22 07:50:50, Jean-Baptiste Onofre <jb@nanthrax.net <ma...@nanthrax.net>> wrote: 
>>> Sorry I don’t understand.
>>> 
>>> The quote are used as you can see in my previous email (John Doe is without quote but with space).
>>> 
>>> Regards
>>> JB
>>> 
>>>> Le 22 juil. 2020 à 09:32, J. Brebec <jeremie.brebec@gmail.com <ma...@gmail.com>> a écrit :
>>>> 
>>>> Thanks.
>>>> 
>>>> It works indeed if I doesn't use double quotes and quote every spaces and single quote. It just looks.. not usual to have to use a backslash before a single quote to be valid syntaxically but this backslash is visible by the command.
>>>> 
>>>> I have this behavior in all my command (and the camel too), but your workaround helped me, thanks.
>>>> 
>>>> 
>>>> On 2020/07/22 06:29:10, Jean-Baptiste Onofre <jb@nanthrax.net <ma...@nanthrax.net>> wrote: 
>>>>> Hi,
>>>>> 
>>>>> I just tested with Karaf Command example:
>>>>> 
>>>>> karaf@root()> feature:repo-add mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
>>>>> Adding feature url mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
>>>>> karaf@root()> feature:install karaf-command-example-provider 
>>>>> karaf@root()> feature:install karaf-command-example 
>>>>> karaf@root()> booking:list 
>>>>> ID │ Flight │ Customer
>>>>> ───┼────────┼─────────
>>>>> karaf@root()> booking:add AF520 "John Doe"
>>>>> karaf@root()> booking:list
>>>>> ID      │ Flight   │ Customer
>>>>> ────────┼──────────┼─────────
>>>>> 7187096 │ John Doe │ AF520
>>>>> 
>>>>> It just works fine with double quotes as you can see.
>>>>> 
>>>>> Backslash also works:
>>>>> 
>>>>> karaf@root()> booking:add FOO Other\ Test
>>>>> karaf@root()> booking:list
>>>>> ID      │ Flight     │ Customer
>>>>> ────────┼────────────┼─────────
>>>>> 2677320 │ Other Test │ FOO
>>>>> 7187096 │ John Doe   │ AF520
>>>>> 
>>>>> Do you have the problem specifically with camel commands or generally speaking ?
>>>>> 
>>>>> If it’s only with Camel commands, I will take a look specifically to Camel.
>>>>> 
>>>>> Regards
>>>>> JB
>>>>> 
>>>>>> Le 21 juil. 2020 à 15:24, J. Brebec <jeremie.brebec@gmail.com <ma...@gmail.com>> a écrit :
>>>>>> 
>>>>>> A simple example with camel and Karaf 4.2.9:
>>>>>> 
>>>>>> karaf@root()> camel:component-list "a'b"
>>>>>> Error executing command: unexpected EOT looking for matching quote: '
>>>>>> karaf@root()> camel:component-list "a\'b"
>>>>>> Camel context a\'b not found.
>>>>>> 
>>>>>> Without a quote "a'b" is invalid.
>>>>>> With a backslash, "a\'b" is valid, however, the command "sees" the backslash (and I don't think every command should handle quoting in an argument?)
>>>>>> 
>>>>>> If I use a native gogo(jline?) command, it's working:
>>>>>> 
>>>>>> karaf@root()> echo "a\'b"
>>>>>> a'b
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> On 2020/07/21 12:13:42, Jean-Baptiste Onofre <jb@nanthrax.net <ma...@nanthrax.net>> wrote: 
>>>>>>> Hi,
>>>>>>> 
>>>>>>> Assuming the last argument is String, did you try " and \" ?
>>>>>>> 
>>>>>>> I just try and it works fine for me (on Linux and Mac).
>>>>>>> 
>>>>>>> Can you provide some environment details to me please ?
>>>>>>> 
>>>>>>> Thanks !
>>>>>>> Regards
>>>>>>> JB
>>>>>>> 
>>>>>>>> Le 21 juil. 2020 à 10:08, J. Brebec <jeremie.brebec@gmail.com <ma...@gmail.com>> a écrit :
>>>>>>>> 
>>>>>>>> Hello,
>>>>>>>> 
>>>>>>>> I have a Karaf shell command which take a String parameters.
>>>>>>>> How can I call it with a parameters with space and quote ?
>>>>>>>> 
>>>>>>>> this doesn't work (the command is not executed with a error about a non-matched quote)
>>>>>>>> ns:mycmd "xx n'est pas conforme"
>>>>>>>> 
>>>>>>>> this doesn't work either: the command is executed, but the backlash is seen by my command
>>>>>>>> ns:mycmd "xx n\'est pas conforme"
>>>>>>>> 
>>>>>>>> I didn't found the right syntax..
>>>>>>>> 
>>>>>>>> thanks!
>>>>>>>> 
>>>>>>>> Jérémie
>>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>> 
>>>>> 
>>> 
>>> 
> 


Re: Shell & Quote

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Ah ok I understand now.

Right now, the only way is to escape space and single quote.

For instance John\ O\’Deer will end with John O’Deer.

However, the double quote should do the escape for you, but we have the issue due to Felix Gogo Runtime:
java.io.EOFException: unexpected EOT looking for matching quote: '

That’s due to the Felix Gogo runtime update and a change we did there.

Let me create a Jira and fix that.

Sorry for the inconvenience.

Regards
JB

> Le 22 juil. 2020 à 13:20, J. Brebec <je...@gmail.com> a écrit :
> 
> Sorry. My issue is not about double quote or spaces, it's about spaces and single quote (or apostrophe). For example, I have commands which take a query as parameter. I used to write the query with doubles quotes, because there is a lot of spaces. However, I can't use an apostrophe in this kind of query.
> 
> If I use your example below, you can see it "looks" like using a quote worked because the syntax error disappears. however it's not, an invalid user has been created with a backslash.
> 
> karaf@root()> feature:repo-add mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
> Adding feature url mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
> karaf@root()> feature:install karaf-command-example-provider
> karaf@root()> feature:install karaf-command-example
> karaf@root()> booking:list
> ID | Flight | Customer
> ---+--------+---------
> karaf@root()> booking:add X1 "John O'Connor"
> Error executing command: unexpected EOT looking for matching quote: '
> karaf@root()> booking:add X1 "John O\'Connor"
> karaf@root()> booking:list
> ID      | Flight         | Customer
> --------+----------------+---------
> 9198438 | John O\'Connor | X1
> karaf@root()> booking:add X2 John\ O\'Connor
> karaf@root()> booking:list
> ID      | Flight         | Customer
> --------+----------------+---------
> 6573975 | John O'Connor  | X2
> 9198438 | John O\'Connor | X1
> 
> On 2020/07/22 07:50:50, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote: 
>> Sorry I don’t understand.
>> 
>> The quote are used as you can see in my previous email (John Doe is without quote but with space).
>> 
>> Regards
>> JB
>> 
>>> Le 22 juil. 2020 à 09:32, J. Brebec <je...@gmail.com> a écrit :
>>> 
>>> Thanks.
>>> 
>>> It works indeed if I doesn't use double quotes and quote every spaces and single quote. It just looks.. not usual to have to use a backslash before a single quote to be valid syntaxically but this backslash is visible by the command.
>>> 
>>> I have this behavior in all my command (and the camel too), but your workaround helped me, thanks.
>>> 
>>> 
>>> On 2020/07/22 06:29:10, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote: 
>>>> Hi,
>>>> 
>>>> I just tested with Karaf Command example:
>>>> 
>>>> karaf@root()> feature:repo-add mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
>>>> Adding feature url mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
>>>> karaf@root()> feature:install karaf-command-example-provider 
>>>> karaf@root()> feature:install karaf-command-example 
>>>> karaf@root()> booking:list 
>>>> ID │ Flight │ Customer
>>>> ───┼────────┼─────────
>>>> karaf@root()> booking:add AF520 "John Doe"
>>>> karaf@root()> booking:list
>>>> ID      │ Flight   │ Customer
>>>> ────────┼──────────┼─────────
>>>> 7187096 │ John Doe │ AF520
>>>> 
>>>> It just works fine with double quotes as you can see.
>>>> 
>>>> Backslash also works:
>>>> 
>>>> karaf@root()> booking:add FOO Other\ Test
>>>> karaf@root()> booking:list
>>>> ID      │ Flight     │ Customer
>>>> ────────┼────────────┼─────────
>>>> 2677320 │ Other Test │ FOO
>>>> 7187096 │ John Doe   │ AF520
>>>> 
>>>> Do you have the problem specifically with camel commands or generally speaking ?
>>>> 
>>>> If it’s only with Camel commands, I will take a look specifically to Camel.
>>>> 
>>>> Regards
>>>> JB
>>>> 
>>>>> Le 21 juil. 2020 à 15:24, J. Brebec <je...@gmail.com> a écrit :
>>>>> 
>>>>> A simple example with camel and Karaf 4.2.9:
>>>>> 
>>>>> karaf@root()> camel:component-list "a'b"
>>>>> Error executing command: unexpected EOT looking for matching quote: '
>>>>> karaf@root()> camel:component-list "a\'b"
>>>>> Camel context a\'b not found.
>>>>> 
>>>>> Without a quote "a'b" is invalid.
>>>>> With a backslash, "a\'b" is valid, however, the command "sees" the backslash (and I don't think every command should handle quoting in an argument?)
>>>>> 
>>>>> If I use a native gogo(jline?) command, it's working:
>>>>> 
>>>>> karaf@root()> echo "a\'b"
>>>>> a'b
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> On 2020/07/21 12:13:42, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote: 
>>>>>> Hi,
>>>>>> 
>>>>>> Assuming the last argument is String, did you try " and \" ?
>>>>>> 
>>>>>> I just try and it works fine for me (on Linux and Mac).
>>>>>> 
>>>>>> Can you provide some environment details to me please ?
>>>>>> 
>>>>>> Thanks !
>>>>>> Regards
>>>>>> JB
>>>>>> 
>>>>>>> Le 21 juil. 2020 à 10:08, J. Brebec <je...@gmail.com> a écrit :
>>>>>>> 
>>>>>>> Hello,
>>>>>>> 
>>>>>>> I have a Karaf shell command which take a String parameters.
>>>>>>> How can I call it with a parameters with space and quote ?
>>>>>>> 
>>>>>>> this doesn't work (the command is not executed with a error about a non-matched quote)
>>>>>>> ns:mycmd "xx n'est pas conforme"
>>>>>>> 
>>>>>>> this doesn't work either: the command is executed, but the backlash is seen by my command
>>>>>>> ns:mycmd "xx n\'est pas conforme"
>>>>>>> 
>>>>>>> I didn't found the right syntax..
>>>>>>> 
>>>>>>> thanks!
>>>>>>> 
>>>>>>> Jérémie
>>>>>>> 
>>>>>> 
>>>>>> 
>>>> 
>>>> 
>> 
>> 


Re: Shell & Quote

Posted by "J. Brebec" <je...@gmail.com>.
Sorry. My issue is not about double quote or spaces, it's about spaces and single quote (or apostrophe). For example, I have commands which take a query as parameter. I used to write the query with doubles quotes, because there is a lot of spaces. However, I can't use an apostrophe in this kind of query.

If I use your example below, you can see it "looks" like using a quote worked because the syntax error disappears. however it's not, an invalid user has been created with a backslash.

karaf@root()> feature:repo-add mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
Adding feature url mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
karaf@root()> feature:install karaf-command-example-provider
karaf@root()> feature:install karaf-command-example
karaf@root()> booking:list
ID | Flight | Customer
---+--------+---------
karaf@root()> booking:add X1 "John O'Connor"
Error executing command: unexpected EOT looking for matching quote: '
karaf@root()> booking:add X1 "John O\'Connor"
karaf@root()> booking:list
ID      | Flight         | Customer
--------+----------------+---------
9198438 | John O\'Connor | X1
karaf@root()> booking:add X2 John\ O\'Connor
karaf@root()> booking:list
ID      | Flight         | Customer
--------+----------------+---------
6573975 | John O'Connor  | X2
9198438 | John O\'Connor | X1

On 2020/07/22 07:50:50, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote: 
> Sorry I don’t understand.
> 
> The quote are used as you can see in my previous email (John Doe is without quote but with space).
> 
> Regards
> JB
> 
> > Le 22 juil. 2020 à 09:32, J. Brebec <je...@gmail.com> a écrit :
> > 
> > Thanks.
> > 
> > It works indeed if I doesn't use double quotes and quote every spaces and single quote. It just looks.. not usual to have to use a backslash before a single quote to be valid syntaxically but this backslash is visible by the command.
> > 
> > I have this behavior in all my command (and the camel too), but your workaround helped me, thanks.
> > 
> > 
> > On 2020/07/22 06:29:10, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote: 
> >> Hi,
> >> 
> >> I just tested with Karaf Command example:
> >> 
> >> karaf@root()> feature:repo-add mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
> >> Adding feature url mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
> >> karaf@root()> feature:install karaf-command-example-provider 
> >> karaf@root()> feature:install karaf-command-example 
> >> karaf@root()> booking:list 
> >> ID │ Flight │ Customer
> >> ───┼────────┼─────────
> >> karaf@root()> booking:add AF520 "John Doe"
> >> karaf@root()> booking:list
> >> ID      │ Flight   │ Customer
> >> ────────┼──────────┼─────────
> >> 7187096 │ John Doe │ AF520
> >> 
> >> It just works fine with double quotes as you can see.
> >> 
> >> Backslash also works:
> >> 
> >> karaf@root()> booking:add FOO Other\ Test
> >> karaf@root()> booking:list
> >> ID      │ Flight     │ Customer
> >> ────────┼────────────┼─────────
> >> 2677320 │ Other Test │ FOO
> >> 7187096 │ John Doe   │ AF520
> >> 
> >> Do you have the problem specifically with camel commands or generally speaking ?
> >> 
> >> If it’s only with Camel commands, I will take a look specifically to Camel.
> >> 
> >> Regards
> >> JB
> >> 
> >>> Le 21 juil. 2020 à 15:24, J. Brebec <je...@gmail.com> a écrit :
> >>> 
> >>> A simple example with camel and Karaf 4.2.9:
> >>> 
> >>> karaf@root()> camel:component-list "a'b"
> >>> Error executing command: unexpected EOT looking for matching quote: '
> >>> karaf@root()> camel:component-list "a\'b"
> >>> Camel context a\'b not found.
> >>> 
> >>> Without a quote "a'b" is invalid.
> >>> With a backslash, "a\'b" is valid, however, the command "sees" the backslash (and I don't think every command should handle quoting in an argument?)
> >>> 
> >>> If I use a native gogo(jline?) command, it's working:
> >>> 
> >>> karaf@root()> echo "a\'b"
> >>> a'b
> >>> 
> >>> 
> >>> 
> >>> 
> >>> 
> >>> On 2020/07/21 12:13:42, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote: 
> >>>> Hi,
> >>>> 
> >>>> Assuming the last argument is String, did you try " and \" ?
> >>>> 
> >>>> I just try and it works fine for me (on Linux and Mac).
> >>>> 
> >>>> Can you provide some environment details to me please ?
> >>>> 
> >>>> Thanks !
> >>>> Regards
> >>>> JB
> >>>> 
> >>>>> Le 21 juil. 2020 à 10:08, J. Brebec <je...@gmail.com> a écrit :
> >>>>> 
> >>>>> Hello,
> >>>>> 
> >>>>> I have a Karaf shell command which take a String parameters.
> >>>>> How can I call it with a parameters with space and quote ?
> >>>>> 
> >>>>> this doesn't work (the command is not executed with a error about a non-matched quote)
> >>>>> ns:mycmd "xx n'est pas conforme"
> >>>>> 
> >>>>> this doesn't work either: the command is executed, but the backlash is seen by my command
> >>>>> ns:mycmd "xx n\'est pas conforme"
> >>>>> 
> >>>>> I didn't found the right syntax..
> >>>>> 
> >>>>> thanks!
> >>>>> 
> >>>>> Jérémie
> >>>>> 
> >>>> 
> >>>> 
> >> 
> >> 
> 
> 

Re: Shell & Quote

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Sorry I don’t understand.

The quote are used as you can see in my previous email (John Doe is without quote but with space).

Regards
JB

> Le 22 juil. 2020 à 09:32, J. Brebec <je...@gmail.com> a écrit :
> 
> Thanks.
> 
> It works indeed if I doesn't use double quotes and quote every spaces and single quote. It just looks.. not usual to have to use a backslash before a single quote to be valid syntaxically but this backslash is visible by the command.
> 
> I have this behavior in all my command (and the camel too), but your workaround helped me, thanks.
> 
> 
> On 2020/07/22 06:29:10, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote: 
>> Hi,
>> 
>> I just tested with Karaf Command example:
>> 
>> karaf@root()> feature:repo-add mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
>> Adding feature url mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
>> karaf@root()> feature:install karaf-command-example-provider 
>> karaf@root()> feature:install karaf-command-example 
>> karaf@root()> booking:list 
>> ID │ Flight │ Customer
>> ───┼────────┼─────────
>> karaf@root()> booking:add AF520 "John Doe"
>> karaf@root()> booking:list
>> ID      │ Flight   │ Customer
>> ────────┼──────────┼─────────
>> 7187096 │ John Doe │ AF520
>> 
>> It just works fine with double quotes as you can see.
>> 
>> Backslash also works:
>> 
>> karaf@root()> booking:add FOO Other\ Test
>> karaf@root()> booking:list
>> ID      │ Flight     │ Customer
>> ────────┼────────────┼─────────
>> 2677320 │ Other Test │ FOO
>> 7187096 │ John Doe   │ AF520
>> 
>> Do you have the problem specifically with camel commands or generally speaking ?
>> 
>> If it’s only with Camel commands, I will take a look specifically to Camel.
>> 
>> Regards
>> JB
>> 
>>> Le 21 juil. 2020 à 15:24, J. Brebec <je...@gmail.com> a écrit :
>>> 
>>> A simple example with camel and Karaf 4.2.9:
>>> 
>>> karaf@root()> camel:component-list "a'b"
>>> Error executing command: unexpected EOT looking for matching quote: '
>>> karaf@root()> camel:component-list "a\'b"
>>> Camel context a\'b not found.
>>> 
>>> Without a quote "a'b" is invalid.
>>> With a backslash, "a\'b" is valid, however, the command "sees" the backslash (and I don't think every command should handle quoting in an argument?)
>>> 
>>> If I use a native gogo(jline?) command, it's working:
>>> 
>>> karaf@root()> echo "a\'b"
>>> a'b
>>> 
>>> 
>>> 
>>> 
>>> 
>>> On 2020/07/21 12:13:42, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote: 
>>>> Hi,
>>>> 
>>>> Assuming the last argument is String, did you try " and \" ?
>>>> 
>>>> I just try and it works fine for me (on Linux and Mac).
>>>> 
>>>> Can you provide some environment details to me please ?
>>>> 
>>>> Thanks !
>>>> Regards
>>>> JB
>>>> 
>>>>> Le 21 juil. 2020 à 10:08, J. Brebec <je...@gmail.com> a écrit :
>>>>> 
>>>>> Hello,
>>>>> 
>>>>> I have a Karaf shell command which take a String parameters.
>>>>> How can I call it with a parameters with space and quote ?
>>>>> 
>>>>> this doesn't work (the command is not executed with a error about a non-matched quote)
>>>>> ns:mycmd "xx n'est pas conforme"
>>>>> 
>>>>> this doesn't work either: the command is executed, but the backlash is seen by my command
>>>>> ns:mycmd "xx n\'est pas conforme"
>>>>> 
>>>>> I didn't found the right syntax..
>>>>> 
>>>>> thanks!
>>>>> 
>>>>> Jérémie
>>>>> 
>>>> 
>>>> 
>> 
>> 


Re: Shell & Quote

Posted by "J. Brebec" <je...@gmail.com>.
Thanks.

It works indeed if I doesn't use double quotes and quote every spaces and single quote. It just looks.. not usual to have to use a backslash before a single quote to be valid syntaxically but this backslash is visible by the command.

I have this behavior in all my command (and the camel too), but your workaround helped me, thanks.


On 2020/07/22 06:29:10, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote: 
> Hi,
> 
> I just tested with Karaf Command example:
> 
> karaf@root()> feature:repo-add mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
> Adding feature url mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
> karaf@root()> feature:install karaf-command-example-provider 
> karaf@root()> feature:install karaf-command-example 
> karaf@root()> booking:list 
> ID │ Flight │ Customer
> ───┼────────┼─────────
> karaf@root()> booking:add AF520 "John Doe"
> karaf@root()> booking:list
> ID      │ Flight   │ Customer
> ────────┼──────────┼─────────
> 7187096 │ John Doe │ AF520
> 
> It just works fine with double quotes as you can see.
> 
> Backslash also works:
> 
> karaf@root()> booking:add FOO Other\ Test
> karaf@root()> booking:list
> ID      │ Flight     │ Customer
> ────────┼────────────┼─────────
> 2677320 │ Other Test │ FOO
> 7187096 │ John Doe   │ AF520
> 
> Do you have the problem specifically with camel commands or generally speaking ?
> 
> If it’s only with Camel commands, I will take a look specifically to Camel.
> 
> Regards
> JB
> 
> > Le 21 juil. 2020 à 15:24, J. Brebec <je...@gmail.com> a écrit :
> > 
> > A simple example with camel and Karaf 4.2.9:
> > 
> > karaf@root()> camel:component-list "a'b"
> > Error executing command: unexpected EOT looking for matching quote: '
> > karaf@root()> camel:component-list "a\'b"
> > Camel context a\'b not found.
> > 
> > Without a quote "a'b" is invalid.
> > With a backslash, "a\'b" is valid, however, the command "sees" the backslash (and I don't think every command should handle quoting in an argument?)
> > 
> > If I use a native gogo(jline?) command, it's working:
> > 
> > karaf@root()> echo "a\'b"
> > a'b
> > 
> > 
> > 
> > 
> > 
> > On 2020/07/21 12:13:42, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote: 
> >> Hi,
> >> 
> >> Assuming the last argument is String, did you try " and \" ?
> >> 
> >> I just try and it works fine for me (on Linux and Mac).
> >> 
> >> Can you provide some environment details to me please ?
> >> 
> >> Thanks !
> >> Regards
> >> JB
> >> 
> >>> Le 21 juil. 2020 à 10:08, J. Brebec <je...@gmail.com> a écrit :
> >>> 
> >>> Hello,
> >>> 
> >>> I have a Karaf shell command which take a String parameters.
> >>> How can I call it with a parameters with space and quote ?
> >>> 
> >>> this doesn't work (the command is not executed with a error about a non-matched quote)
> >>> ns:mycmd "xx n'est pas conforme"
> >>> 
> >>> this doesn't work either: the command is executed, but the backlash is seen by my command
> >>> ns:mycmd "xx n\'est pas conforme"
> >>> 
> >>> I didn't found the right syntax..
> >>> 
> >>> thanks!
> >>> 
> >>> Jérémie
> >>> 
> >> 
> >> 
> 
> 

Re: Shell & Quote

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Hi,

I just tested with Karaf Command example:

karaf@root()> feature:repo-add mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
Adding feature url mvn:org.apache.karaf.examples/karaf-command-example-features/4.2.9/xml
karaf@root()> feature:install karaf-command-example-provider 
karaf@root()> feature:install karaf-command-example 
karaf@root()> booking:list 
ID │ Flight │ Customer
───┼────────┼─────────
karaf@root()> booking:add AF520 "John Doe"
karaf@root()> booking:list
ID      │ Flight   │ Customer
────────┼──────────┼─────────
7187096 │ John Doe │ AF520

It just works fine with double quotes as you can see.

Backslash also works:

karaf@root()> booking:add FOO Other\ Test
karaf@root()> booking:list
ID      │ Flight     │ Customer
────────┼────────────┼─────────
2677320 │ Other Test │ FOO
7187096 │ John Doe   │ AF520

Do you have the problem specifically with camel commands or generally speaking ?

If it’s only with Camel commands, I will take a look specifically to Camel.

Regards
JB

> Le 21 juil. 2020 à 15:24, J. Brebec <je...@gmail.com> a écrit :
> 
> A simple example with camel and Karaf 4.2.9:
> 
> karaf@root()> camel:component-list "a'b"
> Error executing command: unexpected EOT looking for matching quote: '
> karaf@root()> camel:component-list "a\'b"
> Camel context a\'b not found.
> 
> Without a quote "a'b" is invalid.
> With a backslash, "a\'b" is valid, however, the command "sees" the backslash (and I don't think every command should handle quoting in an argument?)
> 
> If I use a native gogo(jline?) command, it's working:
> 
> karaf@root()> echo "a\'b"
> a'b
> 
> 
> 
> 
> 
> On 2020/07/21 12:13:42, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote: 
>> Hi,
>> 
>> Assuming the last argument is String, did you try " and \" ?
>> 
>> I just try and it works fine for me (on Linux and Mac).
>> 
>> Can you provide some environment details to me please ?
>> 
>> Thanks !
>> Regards
>> JB
>> 
>>> Le 21 juil. 2020 à 10:08, J. Brebec <je...@gmail.com> a écrit :
>>> 
>>> Hello,
>>> 
>>> I have a Karaf shell command which take a String parameters.
>>> How can I call it with a parameters with space and quote ?
>>> 
>>> this doesn't work (the command is not executed with a error about a non-matched quote)
>>> ns:mycmd "xx n'est pas conforme"
>>> 
>>> this doesn't work either: the command is executed, but the backlash is seen by my command
>>> ns:mycmd "xx n\'est pas conforme"
>>> 
>>> I didn't found the right syntax..
>>> 
>>> thanks!
>>> 
>>> Jérémie
>>> 
>> 
>> 


Re: Shell & Quote

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
My point is, you have to use foo\ bar (without quotes).

Did you try with single quote instead of double ?

I will check anyway with a test command.

Regards
JB

> Le 21 juil. 2020 à 15:24, J. Brebec <je...@gmail.com> a écrit :
> 
> A simple example with camel and Karaf 4.2.9:
> 
> karaf@root()> camel:component-list "a'b"
> Error executing command: unexpected EOT looking for matching quote: '
> karaf@root()> camel:component-list "a\'b"
> Camel context a\'b not found.
> 
> Without a quote "a'b" is invalid.
> With a backslash, "a\'b" is valid, however, the command "sees" the backslash (and I don't think every command should handle quoting in an argument?)
> 
> If I use a native gogo(jline?) command, it's working:
> 
> karaf@root()> echo "a\'b"
> a'b
> 
> 
> 
> 
> 
> On 2020/07/21 12:13:42, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote: 
>> Hi,
>> 
>> Assuming the last argument is String, did you try " and \" ?
>> 
>> I just try and it works fine for me (on Linux and Mac).
>> 
>> Can you provide some environment details to me please ?
>> 
>> Thanks !
>> Regards
>> JB
>> 
>>> Le 21 juil. 2020 à 10:08, J. Brebec <je...@gmail.com> a écrit :
>>> 
>>> Hello,
>>> 
>>> I have a Karaf shell command which take a String parameters.
>>> How can I call it with a parameters with space and quote ?
>>> 
>>> this doesn't work (the command is not executed with a error about a non-matched quote)
>>> ns:mycmd "xx n'est pas conforme"
>>> 
>>> this doesn't work either: the command is executed, but the backlash is seen by my command
>>> ns:mycmd "xx n\'est pas conforme"
>>> 
>>> I didn't found the right syntax..
>>> 
>>> thanks!
>>> 
>>> Jérémie
>>> 
>> 
>> 


Re: Shell & Quote

Posted by "J. Brebec" <je...@gmail.com>.
A simple example with camel and Karaf 4.2.9:

karaf@root()> camel:component-list "a'b"
Error executing command: unexpected EOT looking for matching quote: '
karaf@root()> camel:component-list "a\'b"
Camel context a\'b not found.

Without a quote "a'b" is invalid.
With a backslash, "a\'b" is valid, however, the command "sees" the backslash (and I don't think every command should handle quoting in an argument?)

If I use a native gogo(jline?) command, it's working:

karaf@root()> echo "a\'b"
a'b





On 2020/07/21 12:13:42, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote: 
> Hi,
> 
> Assuming the last argument is String, did you try " and \" ?
> 
> I just try and it works fine for me (on Linux and Mac).
> 
> Can you provide some environment details to me please ?
> 
> Thanks !
> Regards
> JB
> 
> > Le 21 juil. 2020 à 10:08, J. Brebec <je...@gmail.com> a écrit :
> > 
> > Hello,
> > 
> > I have a Karaf shell command which take a String parameters.
> > How can I call it with a parameters with space and quote ?
> > 
> > this doesn't work (the command is not executed with a error about a non-matched quote)
> > ns:mycmd "xx n'est pas conforme"
> > 
> > this doesn't work either: the command is executed, but the backlash is seen by my command
> > ns:mycmd "xx n\'est pas conforme"
> > 
> > I didn't found the right syntax..
> > 
> > thanks!
> > 
> > Jérémie
> > 
> 
> 

Re: Shell & Quote

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Hi,

Assuming the last argument is String, did you try " and \" ?

I just try and it works fine for me (on Linux and Mac).

Can you provide some environment details to me please ?

Thanks !
Regards
JB

> Le 21 juil. 2020 à 10:08, J. Brebec <je...@gmail.com> a écrit :
> 
> Hello,
> 
> I have a Karaf shell command which take a String parameters.
> How can I call it with a parameters with space and quote ?
> 
> this doesn't work (the command is not executed with a error about a non-matched quote)
> ns:mycmd "xx n'est pas conforme"
> 
> this doesn't work either: the command is executed, but the backlash is seen by my command
> ns:mycmd "xx n\'est pas conforme"
> 
> I didn't found the right syntax..
> 
> thanks!
> 
> Jérémie
>