Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16671
| 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 | Sat, 1 Aug 2020 20:47:42 -0400 |
| Lines | 68 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.473.1596329270.2739.bug-bash@gnu.org> (permalink) |
| References | <000301d66834$588493c0$098dbb40$@kalvr.net> <F4821044-5F8D-4B6D-A266-BAC88AE3DC2C@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 1596329271 26541 209.51.188.17 (2 Aug 2020 00:47:51 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | bug-bash@gnu.org |
| To | Kristof Burek <contact@kalvr.net> |
| 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=D 5NXVnOKW5TmE08B4gKk/knMhaGutpP7tV79f74CEoU=; b=dmLf1ujBpRT7q1Bj4 qktzXPAEduRk5aX682Y8h8bCtLl+YkONhXq1m9PBAqmONQrI+FjNfatxuFhVhBhs Ib5ifmofJERnjoGKF/YhcwmyIXZYAkxm/43JQovqgTOI6NeFvbRikC9Y2Yp8TDCt oRxB+KyR4D/i87HEUKSEP8PxxDCCMn8z6BEkCnCFvHcAnDqIKaF7D+BF3uSL2vFj eU9QsaSWgzqO0+sG0NTTlmJuwq+ZjCGzpxbdYnaAMtEJQGI5AaXO3R2CT83h2RDj LEnw8dUT+8MZjWFrchZWpB84o1RGC9KA9LtU2A+0I1exAqS1lgJTpkxKgd53z75m mmNVQ== |
| 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=D5NXVnOKW5TmE08B4gKk/knMhaGutpP7tV79f74CE oU=; b=ixhvjuGXypRDKdFb+ElSzwp/y+HzTs98cXciFZtRTN19kLgCW3lIMDvq2 KEHt7U3V2gm59yEHT7oIZQaMrDL24JVgb+YTQnQ4Y2HlORk6PdxgG9ev0B7ylQVO gGUmiqGRIix+mrSFe38mpqD2hu5c/BMnFmHkjxJLjMnHZtAh0evtsVXwPBIENC+D 4V6IbM3i3ttE99wYZEFGb1enpF7krmFJ4FEvFdLiVA8+fDEbpqxjUzi0Qbfvs50p HVs/sWTG9I88ohKCaDSAypE/HhJ9hfQ8ykN21BqzfGY2YlOt9Ns1av2m4+lvbnPP LZnEvvlMhkKnP/mPTapWoGE6MgTNA== |
| X-ME-Sender | <xms:Lw0mX3wRZeUAJai6fftwhrvNX1xBWZlKbmwo40fmeLBt9V6T7ZAl9Q> |
| X-ME-Proxy-Cause | gggruggvucftvghtrhhoucdtuddrgeduiedrjedugdegtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurheptggguffhjgffgffkfhfvofesthhqmh dthhdtjeenucfhrhhomhepnfgrfihrvghntggvpgggvghljoiiqhhuvgiiuceovhhqsehl rghrrhihvhdrmhgvqeenucggtffrrghtthgvrhhnpedukeejtdelhedvudfhveelgeetff etkeehvdehjeetleffvdegtdejvdeuueegieenucfkphepuddttddruddvrddujeekrddv feenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehvqh eslhgrrhhrhihvrdhmvg |
| X-ME-Proxy | <xmx:Lw0mX_T1A2iGX_TVwZ3iKbVHZSrOEtvRrIsri_LEYs_M1GwbH2tDeQ> <xmx:Lw0mXxVJ-SRp4fTNQdurPc9AZfp7rlEpkAJjQXXNhsKyJfDx7BvZTg> <xmx:Lw0mXxhoDJC5ACYMxd4c1VDrP1DFQiGuL31LQaX55tqOYhMzwWU3UQ> <xmx:Lw0mX8OvH28sTbOgQbABrkuYX1Kr-mz9GgZODzYFcyhpH0kvTZ_mBQ> |
| In-Reply-To | <000301d66834$588493c0$098dbb40$@kalvr.net> |
| X-Mailer | Apple Mail (2.3445.104.15) |
| Received-SPF | pass client-ip=64.147.123.21; envelope-from=vq@larryv.me; helo=wout5-smtp.messagingengine.com |
| X-detected-operating-system | by eggs.gnu.org: First seen = 2020/08/01 20:47:44 |
| X-ACL-Warn | Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] |
| X-Spam_score_int | -27 |
| X-Spam_score | -2.8 |
| X-Spam_bar | -- |
| X-Spam_report | (-2.8 / 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham 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 | <F4821044-5F8D-4B6D-A266-BAC88AE3DC2C@larryv.me> |
| X-Mailman-Original-References | <000301d66834$588493c0$098dbb40$@kalvr.net> |
| Xref | csiph.com gnu.bash.bug:16671 |
Show key headers only | View raw
> On Aug 1, 2020, at 2:48 PM, Kristof Burek <contact@kalvr.net> wrote:
>
> set -u # Bash complains and exits on first use of an unbound name
With respect to set -u neither the bash man page nor POSIX.1-2017
refer to "use" of parameters, but to their *expansion*.
> s+='t' # Line 8 - Bash should fail here
I don't see any parameter expansion here, and ksh and zsh agree:
% bash --version | head -n 1; ksh --version; zsh --version
GNU bash, version 5.0.17(1)-release (x86_64-apple-darwin18.7.0)
version sh (AT&T Research) 93u+ 2012-08-01
zsh 5.8 (x86_64-apple-darwin18.7.0)
% bash -c 'set -u; unset s; s+=t; printf "<%s>\\n" "$s"'
<t>
% ksh -c 'set -u; unset s; s+=t; printf "<%s>\\n" "$s"'
<t>
% zsh -c 'set -u; unset s; s+=t; printf "<%s>\\n" "$s"'
<t>
Presumably none of these shells implements s+=t as s=${s}t.
> #t=''
> t=${t}'t' # Line 12, Bash fails until line 11 loses its starting #
This fails as you expect because you're expanding $t in there.
> u+=('t') # Line 15, Bash should fail here
Again, I don't see any parameter expansion here, and ksh and zsh
agree:
% bash -c 'set -u; unset u; u+=(t); printf "<%s>\\n" "${u[@]}"'
<t>
% ksh -c 'set -u; unset u; u+=(t); printf "<%s>\\n" "${u[@]}"'
<t>
% zsh -c 'set -u; unset u; u+=(t); printf "<%s>\\n" "${u[@]}"'
<t>
Presumably none of these shells implements u+=(t) as u=("${u[@]}" t).
> let v+=1 # Line 18, Once line 11 is uncommented, Bash fails here
I haven't seen the code for arithmetic expansion, but I assume it
treats v+=1 as morally equivalent to v=${v}+1 (à la C99). Thus there
*is* an expansion, which fails under set -u. Regardless of the
particulars, ksh and zsh again agree:
% bash -c 'set -u; unset v; let v+=1; printf "<%s>\\n" "$v"'
bash: v: unbound variable
% ksh -c 'set -u; unset v; let v+=1; printf "<%s>\\n" "$v"'
ksh: let: v: parameter not set
ksh: v: parameter not set
% zsh -c 'set -u; unset v; let v+=1; printf "<%s>\\n" "$v"'
zsh:1: v: parameter not set
zsh:1: v: parameter not set
> When this issue is fixed, I dare say a few perfectly working scripts
> will fall over, but I hope not too many of mine.
It's not clear that there's a bug here.
vq
Back to gnu.bash.bug | Previous | Next | Find similar
Re: set -u not working as expected Lawrence Velázquez <vq@larryv.me> - 2020-08-01 20:47 -0400
csiph-web