Path: csiph.com!goblin3!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: =?utf-8?Q?Lawrence_Vel=C3=A1zquez?= Newsgroups: gnu.bash.bug Subject: Re: set -u not working as expected Date: Sun, 2 Aug 2020 01:12:56 -0400 Lines: 52 Approved: bug-bash@gnu.org Message-ID: References: <000301d66834$588493c0$098dbb40$@kalvr.net> <1867D8FC-85DD-4406-A239-3002913493AB@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 1596345183 3936 209.51.188.17 (2 Aug 2020 05:13:03 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash@gnu.org To: Kristof Burek 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=A mVTaL7vmaZ5WCd6+f+poSoxNyMamU6UWxJnN9+AuPg=; b=mbN/fVQEdJyrUsWas fO9nCXf67piM6rvQT5u/VRREDkO9zsheBBtYi9ZUgjcIeWh8oE/OkQFcpQdr4frp zbM4ksSIoZ5ANKA7sH+zNtYyU8cn36pdJh8TlzzfK3w1VztPM0qSwtOgn2lR7aBN u8QLL0BHhaYkj9EC4/rorAwzQAqiBdl8smRTxev7T0mh4Z5h4wagadnmSrFQlQch 4CzEAVkbPoLbw0Muljvsi59Ej5FHmpoHoxFD3xLt1ZjY8DGWGaBgF72/w1GaECz3 sp+pe6QiWx/yfyzk79etmME9xjH+oL+dd/gpbB/cFww7tN0s+wdAzIRqYug23bql aS+fA== 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=AmVTaL7vmaZ5WCd6+f+poSoxNyMamU6UWxJnN9+Au Pg=; b=tRRwiLV1GeFELSCmvilIgKtVtWQPbd/cd44KWAwDy9tyJQU6b2trjCMja e4YDUJ/2cb6X3kzktqcMw3wUkqf2gBIs4iZmAMU/6e6Rkt6CdTTqAaMMxZvs2cAk vLi/2HNJxMqmipOia+l4KiTUxgbSM2Wl02VkNgwQOGgSbV0yhyO1sY9awGZ2lXuS wvWKcNEeuZ9oYUcBzIZe3tf6FrvbXCCItJy1iVu296E0jAom4J7K2dFouBdM6Qzj O4RcxY/Ru6LTiQ8dmCtagM36DoHHnqIAjYNKq5CgdjPG+i8LV6VxB+qJ74z2qqC4 3Wyq5ibEYkRYIw4pQoCzZwv9XCR4w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrjedugdelfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurheptggguffhjgffgffkfhfvofesthhqmh dthhdtjeenucfhrhhomhepnfgrfihrvghntggvpgggvghljoiiqhhuvgiiuceovhhqsehl rghrrhihvhdrmhgvqeenucggtffrrghtthgvrhhnpedukeejtdelhedvudfhveelgeetff etkeehvdehjeetleffvdegtdejvdeuueegieenucfkphepuddttddruddvrddujeekrddv feenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehvqh eslhgrrhhrhihvrdhmvg X-ME-Proxy: In-Reply-To: X-Mailer: Apple Mail (2.3445.104.15) Received-SPF: pass client-ip=64.147.123.25; envelope-from=vq@larryv.me; helo=wout2-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/02 00:19:24 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <1867D8FC-85DD-4406-A239-3002913493AB@larryv.me> X-Mailman-Original-References: <000301d66834$588493c0$098dbb40$@kalvr.net> Xref: csiph.com gnu.bash.bug:16672 > On Aug 1, 2020, at 8:47 PM, Lawrence Vel=C3=A1zquez = wrote: >=20 > Presumably none of these shells implements u+=3D(t) as u=3D("${u[@]}" = t). Granted, they do disagree on ${u[@]}. % bash -c 'set -u; unset u; u=3D("${u[@]}" t); typeset -p u' declare -a u=3D([0]=3D"t") % ksh -c 'set -u; unset u; u=3D("${u[@]}" t); typeset -p u' typeset -a u=3D(t) % zsh -c 'set -u; unset u; u=3D("${u[@]}" t); typeset -p u' zsh:1: u[@]: parameter not set > I haven't seen the code for arithmetic expansion, but I assume it > treats v+=3D1 as morally equivalent to v=3D${v}+1 (=C3=A0 la C99). = Thus there > *is* an expansion, which fails under set -u. Regardless of the > particulars, ksh and zsh again agree: >=20 > % bash -c 'set -u; unset v; let v+=3D1; printf "<%s>\\n" "$v"' > bash: v: unbound variable > % ksh -c 'set -u; unset v; let v+=3D1; printf "<%s>\\n" "$v"' > ksh: let: v: parameter not set > ksh: v: parameter not set > % zsh -c 'set -u; unset v; let v+=3D1; printf "<%s>\\n" "$v"' > zsh:1: v: parameter not set > zsh:1: v: parameter not set On the other hand... % 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> ...and... % bash -c 'set -u; typeset -i v; v+=3D1; printf "<%s>\\n" "$v"' <1> % ksh -c 'set -u; typeset -i v; v+=3D1; printf "<%s>\\n" "$v"' <1> % zsh -c 'set -u; typeset -i v; v+=3D1; printf "<%s>\\n" "$v"' <1> *shrug* vq=