Re: how to escape single quote?

2010-12-29 Thread Dennis Williamson
On Wed, Dec 29, 2010 at 1:28 AM, ali hagigat  wrote:
> I wonder if anybody knows how to escape a single quote character by
> /bin/sh or bash?
> echo 'ppp\'qqq''
> ppp\qqq
> Please look at the above example and the result.
> Regards
>
>

echo "ppp'qqq"

or

echo 'ppp'\''qqq'



Re: how to escape single quote?

2010-12-29 Thread ali hagigat
Dennis,

Nice. Much appreciated
What logic is it using you think when we use echo 'ppp'\''qqq'?
Why echo 'ppp\'qqq' is not OK? It can not escape single quote by \ !

On Wed, Dec 29, 2010 at 1:11 PM, Dennis Williamson
 wrote:
> On Wed, Dec 29, 2010 at 1:28 AM, ali hagigat  wrote:
>> I wonder if anybody knows how to escape a single quote character by
>> /bin/sh or bash?
>> echo 'ppp\'qqq''
>> ppp\qqq
>> Please look at the above example and the result.
>> Regards
>>
>>
>
> echo "ppp'qqq"
>
> or
>
> echo 'ppp'\''qqq'
>
>



Re: how to escape single quote?

2010-12-29 Thread Pierre Gaston
On Wed, Dec 29, 2010 at 12:44 PM, ali hagigat  wrote:

> Dennis,
>
> Nice. Much appreciated
> What logic is it using you think when we use echo 'ppp'\''qqq'?
>

The logic is:
1) you need to close the quotes with '
2) concatenate a single quotes using another form of quoting for instance:
\' but "'" also works
3) then you reopen the single quote for the rest of your string '

It's not a form of quoting is 3 parts put together 'A'  and \' and 'B'

Why echo 'ppp\'qqq' is not OK? It can not escape single quote by \ !


because \ is not special inside single quotes


Re: Word splitting and arithmetic expansion

2010-12-29 Thread Jan Schampera

Chet Ramey wrote:


Arithmetic expansion is a Posix invention.  It's treated just like every
other expansion: split unless double quoted.  There's no compelling
reason to make it behave differently.


I don't want it to behave differently :)

Okay, so it's just "as is", because by consistent design all expansions 
are subject to WS (with some exceptions).



Pathname expansion happens after word splitting.  Tilde expansion is the
one that's not subject to word splitting.


This is clear, it was an unlucky example (pathname expansion's location 
in the processing is where it is to prevent WS, but tilde expansion is a 
better example since it happens before WS and is excluded from WS).


Thanks.

--
Be conservative in what you do, be liberal in what you accept from others.
- jbp, master of the net, in RFC793