[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: set -u not working as expected
From: |
Lawrence Velázquez |
Subject: |
Re: set -u not working as expected |
Date: |
Sun, 2 Aug 2020 03:34:23 -0400 |
> On Aug 2, 2020, at 2:51 AM, Oğuz <oguzismailuysal@gmail.com> wrote:
>
> `u' has no members, so there's nothing to expand. If you use `${u[0]}' for
> example, you'll see an error, I think how bash and ksh behave is perfectly
> reasonable.
Agreed. Their behavior logically follows from POSIX's carveout for $@.
>> % bash -c 'set -u; typeset -i v; printf "<%s>\\n" "$v"'
>> bash: v: unbound variable
>> % ksh -c 'set -u; typeset -i v; printf "<%s>\\n" "$v"'
>> ksh: v: parameter not set
>> % zsh -c 'set -u; typeset -i v; printf "<%s>\\n" "$v"'
>> <0>
>>
>>
> `typeset -i v' doesn't assign `v', just gives it the integer attribute.
> Again, I can't see any problem with bash and ksh here.
Also agreed, but I was more interested in the next part...
>> % bash -c 'set -u; typeset -i v; v+=1; printf "<%s>\\n" "$v"'
>> <1>
>> % ksh -c 'set -u; typeset -i v; v+=1; printf "<%s>\\n" "$v"'
>> <1>
>> % zsh -c 'set -u; typeset -i v; v+=1; printf "<%s>\\n" "$v"'
>> <1>
...which contrasts with the behavior of let. Someone else will have
to explain this, as I don't know what to make of it.
vq
Re: set -u not working as expected, Chet Ramey, 2020/08/02
Re: set -u not working as expected, Chet Ramey, 2020/08/02