bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: quote removal not performed in arithmetic expansion


From: cpr
Subject: Re: quote removal not performed in arithmetic expansion
Date: Fri, 06 Jun 2003 14:21:54 -0400

----- Original Message -----
From: Christopher Yeoh <cyeoh@samba.org>
Date: Friday, June 6, 2003 3:13 am
Subject: quote removal not performed in arithmetic expansion
> Machine Type: i386-pc-linux-gnu
> 
> Bash Version: 2.05b
> Patch Level: 0
> Release Status: release
> 
> Description:
>        quote removal not performed in arithmetic expansion before
>        arthmetic expression calculated
> 
>        eg:
>        echo $((1+'1'))
>        echo $((1+"1"))
>        echo $((1+\1))
> 
>        all result in syntax errors.

As they all should.

>        According to POSIX 2.6.4 (Arithmetic expression)
> 
>        The expression shall be treated as if it were in
>        double-quotes, except that a double-quote inside the
>        expression is not treated specially. The shell shall expand
>        all tokens in the expression for parameter expansion, command
>        substitution, and quote removal.

This doesn't mean what I think you think it means.  To make the bash
behavior more clear, try enclosing the above expressions in double
quotes instead of $((...)) (remembering to backslash-escape the double
quotes in the second expression).  You'll see that the quoting characters
are preserved by the double-quoting and passed thorough to the arithmetic
evaluator.

Quote removal removes *unquoted* instances of `/', `'', and `"'.

Chet
 
>        
> http://www.opengroup.org/onlinepubs/007904975/utilities/xcu_chap02.html#tag_02_06_04
> 
> 
> _______________________________________________
> Bug-bash mailing list
> Bug-bash@gnu.org
> http://mail.gnu.org/mailman/listinfo/bug-bash
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]