[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] set -u in an arithmetic context
From: |
Eric Blake |
Subject: |
Re: [Help-bash] set -u in an arithmetic context |
Date: |
Thu, 26 Apr 2012 16:04:31 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 |
On 04/26/2012 03:59 PM, Bill Gradwohl wrote:
> On Thu, Apr 26, 2012 at 11:01 AM, Eric Blake <address@hidden> wrote:
>
>> Especially since 'set -u' _does_ affect arithmetic expansion (although I
>> couldn't quickly find such a requirement in POSIX, so we may have a hole
>> in the standard):
>>
>>
>
> We're on the same bash level.
>
> I question the notion of "expansion" in this case. Without the $ or ${}
> wrappers is there "expansion" going on?
In the fact that $((x)) sees 'x', and checks for a shell variable of the
same name, and uses the numeric value of the contents of that shell
variable.
>
> Man bash says that set -u work as part of "parameter expansion". Without
> the $ or ${} wrappers, isn't it just taking whatever the value is an using
> it as is with no expansion?
There is expansion going on. POSIX requires $((x)) and $(($x)) to give
the same output when x is set; so logically, it should require 'set -u'
to cause the same error when x is unset.
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature