Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16673
| Path | csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Oğuz <oguzismailuysal@gmail.com> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: set -u not working as expected |
| Date | Sun, 2 Aug 2020 09:51:16 +0300 |
| Lines | 70 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.488.1596351081.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> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | usenet.stanford.edu 1596351082 7826 209.51.188.17 (2 Aug 2020 06:51:22 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | Kristof Burek <contact@kalvr.net>, "bug-bash@gnu.org" <bug-bash@gnu.org> |
| To | Lawrence Velázquez <vq@larryv.me> |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=O4/6UAxQ+mN/bL08tZjtKIU+QkwEQ/LtZsLEKlPWs3M=; b=qB/Rh5ElwJxxNTlBoyXDx8Hq2uzD8K/wPmwTL9FUpwYQ3fCuKftnImeZmsOlIhkcsS ZQcoO/s0DlVHuHrO4OVpxF/GPsyFg/Zs3krgN8+kDmNfmVfqGsocBTrtIv3M3NZVJW3Q Efy39z2cksqJDHkb3U5xGBiier7v2POLIp7WcnBwcct9Y0kAZBO6HUP5g+sv0ZsNm0gM GLZA6T6dopZwb9gVdymRx9MAcVsrcJ3JaQDySizC6u9Shlzcn6GG/LMVE0lTf+Gfn36j XbyHDEssrKLEUvcAmTDpLtsdFAojF5YLGxSekTXkFhw0ohYM1WqfoN6khRqQOkIf2yiU NEPA== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=O4/6UAxQ+mN/bL08tZjtKIU+QkwEQ/LtZsLEKlPWs3M=; b=tJuZnL8+zAcp4Foc5lmvOt+3xbZ+soNBUUpotyPu4Iz/m8d4nIxXBUtEfDL/x6XUrP deFJ1rCGNLBcA7MoA1XuIekUW9WZIEo7flt+wiPYt0wxqd8LvVY68Rh41QasCO/QZL2U A/d5wqQXEUbxCnB6DXSXhZVD9NyERERBP1WSoufrP7yMGMnuzjR2K081RybuB674YwfA mKKUrDCldWIny7vOJj/ul8UwDuFmBETOuPp02TRSHSFqV3LZAEKHtteEdiIgBkRb6J8m cIJLlHLMLLys741po2iA+P6Jm3jRW8DtvR4amdtxBDr91mvA1bN5RIS7KgmrPiavakL6 bxeQ== |
| X-Gm-Message-State | AOAM531nCBuc3/ogkDNdHE10nn9XARfQoWrEtZH3AZccgP2xvLiwoifY cRDwNMaS76eJ1xwVohTsumM1icWN0S/myg74OUuneVQe |
| X-Google-Smtp-Source | ABdhPJxqfci46bLade0/7+Z+H14OQ6yXcA0sdBKfrkUYo6XAVj4rpqHL5U/TCFAGhhENGElKKLlFEr/VYYCXyED6Dwg= |
| X-Received | by 2002:ac8:6f2c:: with SMTP id i12mr11015647qtv.81.1596351077048; Sat, 01 Aug 2020 23:51:17 -0700 (PDT) |
| In-Reply-To | <1867D8FC-85DD-4406-A239-3002913493AB@larryv.me> |
| Received-SPF | pass client-ip=2607:f8b0:4864:20::830; envelope-from=oguzismailuysal@gmail.com; helo=mail-qt1-x830.google.com |
| X-detected-operating-system | by eggs.gnu.org: No matching host in p0f cache. That's all we know. |
| X-Spam_score_int | -20 |
| X-Spam_score | -2.1 |
| X-Spam_bar | -- |
| X-Spam_report | (-2.1 / 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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no |
| X-Spam_action | no action |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.23 |
| 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 | <CAH7i3Lr7ZCYJVpPZdc9xQMuF_yc_C2q0S9px+NY4prEUkU+24w@mail.gmail.com> |
| X-Mailman-Original-References | <000301d66834$588493c0$098dbb40$@kalvr.net> <F4821044-5F8D-4B6D-A266-BAC88AE3DC2C@larryv.me> <1867D8FC-85DD-4406-A239-3002913493AB@larryv.me> |
| Xref | csiph.com gnu.bash.bug:16673 |
Show key headers only | View raw
2 Ağustos 2020 Pazar tarihinde Lawrence Velázquez <vq@larryv.me> yazdı:
> > On Aug 1, 2020, at 8:47 PM, Lawrence Velázquez <vq@larryv.me> wrote:
> >
> > Presumably none of these shells implements u+=(t) as u=("${u[@]}" t).
>
> Granted, they do disagree on ${u[@]}.
>
> % bash -c 'set -u; unset u; u=("${u[@]}" t); typeset -p u'
> declare -a u=([0]="t")
> % ksh -c 'set -u; unset u; u=("${u[@]}" t); typeset -p u'
> typeset -a u=(t)
> % zsh -c 'set -u; unset u; u=("${u[@]}" t); typeset -p u'
> zsh:1: u[@]: parameter not set
>
>
`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.
> > 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
>
> 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>
>
>
`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.
> ...and...
>
> % 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>
>
> *shrug*
>
> vq
>
--
Oğuz
Back to gnu.bash.bug | Previous | Next | Find similar
Re: set -u not working as expected Oğuz <oguzismailuysal@gmail.com> - 2020-08-02 09:51 +0300
csiph-web