Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16674

Re: set -u not working as expected

Path csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Lawrence Velázquez <vq@larryv.me>
Newsgroups gnu.bash.bug
Subject Re: set -u not working as expected
Date Sun, 2 Aug 2020 03:34:23 -0400
Lines 37
Approved bug-bash@gnu.org
Message-ID <mailman.497.1596353670.2739.bug-bash@gnu.org> (permalink)
References <000301d66834$588493c0$098dbb40$@kalvr.net> <F4821044-5F8D-4B6D-A266-BAC88AE3DC2C@larryv.me> <1867D8FC-85DD-4406-A239-3002913493AB@larryv.me> <CAH7i3Lr7ZCYJVpPZdc9xQMuF_yc_C2q0S9px+NY4prEUkU+24w@mail.gmail.com> <61B2CB9D-3978-4872-B88A-1542CF95B5B9@larryv.me>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0 (Mac OS X Mail 12.4 \(3445.104.15\))
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding quoted-printable
X-Trace usenet.stanford.edu 1596353671 9559 209.51.188.17 (2 Aug 2020 07:34:31 GMT)
X-Complaints-To action@cs.stanford.edu
Cc "bug-bash@gnu.org" <bug-bash@gnu.org>, Kristof Burek <contact@kalvr.net>
To Oğuz <oguzismailuysal@gmail.com>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=larryv.me; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=fm1; bh=Z 9RilVHG0R8UdahQaEL9bK2EOr1h7Ctua5UnPzYG7+I=; b=YPbXK8zoX8cqsmTjY Rd+Vcm8geQJ8HQoyDWeQy6fCV9mNKS+UVt2W+l6eAJJWne/vktVb+uf52ikYY+Sq KsWinXdOLEhaKpe6ygsXxtkRoAQj9VNO4HyT3/g8OWHeiml0XjMv9A5EnXFqCcRc o1e4hsL9QJnyE9gA4rU1FKEiSWsH7VsfyM3vgtlKbYfEo3s0liofj2L65FP4YmMi 4On3vmthVoRh1LQPopSqGIBkiB2OTsPIht6sa2kbcwDA/k2dVnlU5Y2aGp0EBWxa 1WOWjAWqLefYf/JYZSrpMVPDg2aZg0JYlYZvAid43qOV981a9tAkPVJGLzrxsV/O kF9wg==
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=Z9RilVHG0R8UdahQaEL9bK2EOr1h7Ctua5UnPzYG7 +I=; b=dWgauc3ymNjOmM53o6QqXp+maz4Mo0BvZoaFBZlSxjHrxZlJiqLCUPDAQ GVsRhob/vNyexpp4vk0kUXL9xB0kHIDMB8pr+FPWSYC35HwXHMN7Gy06bm1dImwK IoOO4Wu4WBR23MRMWM8ldbTpQSvPsVQnjHX6b4xM/2b8TLrMVvuUCSaOfINukQbR biBiawb+MZvG2c/yQvkWtmsyh5mfhxv/s2LPkFTkJtdEw3xMLCWgn/3qNPAPgopl ow/ebbnvH+qEHyQ4q/TNBTV739kiMH5vk8zQgkgrRTk1y3WK4c2KatA2GSLzcL/+ +OXL/mK5zIxIw+7oNj2oYJCBjC4bg==
X-ME-Sender <xms:gGwmX3pp4FUVJeVBaAPG9IlZCmBc5GzxGe9Lxdgug4vj6w2epiCiDQ>
X-ME-Proxy-Cause gggruggvucftvghtrhhoucdtuddrgeduiedrjedugdduvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpegtggfuhfgjfffgkfhfvffosehtqh hmtdhhtdejnecuhfhrohhmpefnrgifrhgvnhgtvggpgggvlhojiihquhgviicuoehvqhes lhgrrhhrhihvrdhmvgeqnecuggftrfgrthhtvghrnhepudekjedtleehvdduhfevleegte ffteekhedvheejteelffdvgedtjedvueeugeeinecukfhppedujedvrdehkedrvddvjedr ieejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepvh hqsehlrghrrhihvhdrmhgv
X-ME-Proxy <xmx:gGwmXxqhvn9MUoQCbCzMlY9Ryftf6RyIiypBS5e-pIwbMN6bU9B09w> <xmx:gGwmX0NMQLBxRkQpVHSyiZhAkypERyQdW7YdwRtEzZU0j3QfmpG_Yg> <xmx:gGwmX64WjHzdnL4BWZpMe-z6L5x4_kYVTl95WguqWa0kVIuZ_6idIw> <xmx:gGwmXzUdKLxNgaGHjglc8NG5v8QiDE8g7WWV2uxKZwJNR70ho2UUfg>
In-Reply-To <CAH7i3Lr7ZCYJVpPZdc9xQMuF_yc_C2q0S9px+NY4prEUkU+24w@mail.gmail.com>
X-Mailer Apple Mail (2.3445.104.15)
Received-SPF pass client-ip=64.147.123.24; envelope-from=vq@larryv.me; helo=wout1-smtp.messagingengine.com
X-detected-operating-system by eggs.gnu.org: First seen = 2020/08/02 03:34:25
X-ACL-Warn Detected OS = Linux 2.2.x-3.x [generic] [fuzzy]
X-Spam_score_int 5
X-Spam_score 0.5
X-Spam_bar /
X-Spam_report (0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=no autolearn_force=no
X-Spam_action no action
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <61B2CB9D-3978-4872-B88A-1542CF95B5B9@larryv.me>
X-Mailman-Original-References <000301d66834$588493c0$098dbb40$@kalvr.net> <F4821044-5F8D-4B6D-A266-BAC88AE3DC2C@larryv.me> <1867D8FC-85DD-4406-A239-3002913493AB@larryv.me> <CAH7i3Lr7ZCYJVpPZdc9xQMuF_yc_C2q0S9px+NY4prEUkU+24w@mail.gmail.com>
Xref csiph.com gnu.bash.bug:16674

Show key headers only | View raw


> 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

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: set -u not working as expected Lawrence Velázquez <vq@larryv.me> - 2020-08-02 03:34 -0400

csiph-web