Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16737
| Path | csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Andrew Neff <andrew.neff@visionsystemsinc.com> |
| Newsgroups | gnu.bash.bug |
| Subject | Bash parameter transforamtion on empty array triggers unset variable. |
| Date | Mon, 10 Aug 2020 17:52:14 -0400 |
| Lines | 59 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.1503.1597107654.2739.bug-bash@gnu.org> (permalink) |
| References | <CAJjXSE9b8G0aXyc+t58cbYRwFbiN5eX2rpKnyFwg728x5ZQhKQ@mail.gmail.com> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| X-Trace | usenet.stanford.edu 1597107654 17441 209.51.188.17 (11 Aug 2020 01:00:54 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| To | chet@cwru.edu, bash-testers@cwru.edu, bug-bash@gnu.org |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=visionsystemsinc-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=bZUS5+KsO8nM/Q6ljyoX54FJyiUEAsjdQxTWfZMqEd4=; b=K0k4k+OxRc+is7X8/ZDQmwj4JgUkwUKUgcw9FzmkIspcG4iioMzUEw02FhKcP5hDGd 3qbrlwaq3llLZ3QamTY6ogTulGGd/dUawUVfSEcKS9l1h2tUja0lJ4FOt/2g0B47WPPq 61G6yUiQEN6ym6aVjnpOCmobtJlaq1RWmHPIshtJMLfJrKHVyw7hkYCpVVwBuFVGJs7A F+AlCgdD6UQ4eGJDiOUxRunSYX28eJeyujzI1cwo6jqzh4h0/2lAA5lYLit4XtDhqj73 l3V+6QSXVOVg1qzYapaFSBy0Jw9Z9LMtIO4rnuQkWuYzVNmV5z6M1YPL1xGTTQSJifxB bPvA== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=bZUS5+KsO8nM/Q6ljyoX54FJyiUEAsjdQxTWfZMqEd4=; b=HiCqr39LvRKy62MWKonLQy22XZft4KbSQDff8glYTTCaOzlyrdjSyDzTJ8buw32Qjb n6DK1jOzcBM9JklWJ1eAHte1C/HYL0Ow0znJRDqckLJ7J19ELAb/Acp483lCCafR7kfU rWlfyz5dPInCvbZlRmTBbTjZ6uP2iNRqGNNZpPadOsx3tz+H1HcjkY+9Fu8yq4Q3IFgR LaeHhrCehQ6IZLQBqDKqS565fo/NpPsuM2mwnFyvVZ0LPQYUhsNXsm0J4Rq68Udp7Rdx Mel1gY4jHZr4MASKESI4m96Q7d6bsp6aZIENiRT1B2RklgPTjaoahQaLbOkCAKtGO8qI wGlg== |
| X-Gm-Message-State | AOAM533E6axuVjTJkvh0ZHrsXGphtLCcKbGfb+SuIlf6or89a7cks8BY a5k7do3JaYbvBFc7ejQIilznofoW3nbZcE5UXnbPpg== |
| X-Google-Smtp-Source | ABdhPJx+W/lIjLgwZgwgR/EGri4RPJ42Ptkvk0hsqv3q1cNebfE1y+EFTUBnZ7v2vmfBdOl/ihYs3ZkaHU1MBvdEQzA= |
| X-Received | by 2002:aca:4d48:: with SMTP id a69mr1086752oib.39.1597096344808; Mon, 10 Aug 2020 14:52:24 -0700 (PDT) |
| Received-SPF | none client-ip=2607:f8b0:4864:20::230; envelope-from=andrew.neff@visionsystemsinc.com; helo=mail-oi1-x230.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 | -18 |
| X-Spam_score | -1.9 |
| X-Spam_bar | - |
| X-Spam_report | (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no |
| X-Spam_action | no action |
| X-Mailman-Approved-At | Mon, 10 Aug 2020 21:00:53 -0400 |
| 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 | <CAJjXSE9b8G0aXyc+t58cbYRwFbiN5eX2rpKnyFwg728x5ZQhKQ@mail.gmail.com> |
| Xref | csiph.com gnu.bash.bug:16737 |
Show key headers only | View raw
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-musl
Compiler: gcc
Compilation CFLAGS: -g -O2 -Wno-parentheses -Wno-format-security
uname output: Linux 28e237a5e16f 5.5.7-200.fc31.x86_64 #1 SMP Fri Feb 28
17:18:37 UTC 2020 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-musl
Bash Version: 5.1
Patch Level: 0
Release Status: alpha
Description:
I do not know if this is related to bash 5.1 erroneously being
"a little aggressive about skipping over empty strings" mentioned
in "Declaring arrays with empty string in one line is bugged", but using
parameter transformation on an empty array, throws an error if "set -u" is
turned on. This was not how bash 4.4 and 5.0 worked. This bug makes it
impossible to check if an empty variable is an array using parameter
transformation while "set -u" is turned on
Repeat-By:
# Indirection
docker run -it --rm bash:5.1-alpha bash -uc 'foo(){ echo "${!1@a}";
}; bar=(); foo bar'
# Empty array
docker run -it --rm bash:5.1-alpha bash -uc 'bar=(); echo "${bar@a}"'
# Declared unset array
docker run -it --rm bash:5.1-alpha bash -uc 'declare -a bar; echo
"${bar@a}"'
# Empty associative array
docker run -it --rm bash:5.1-alpha bash -uc 'declare -A Bar=();
echo "${Bar@a}"'
# Declared unset associative array
docker run -it --rm bash:5.1-alpha bash -uc 'declare -A Bar; echo
"${Bar@a}"'
# I also tested on bash:devel-20200805, with the same results
Fix:
# All five of the above examples work in bash 4.4 and 5.0, and I
would expect the same behavior in bash 5.1
# Expected behavior that is already there in 5.1 alpha
docker run -it --rm bash:5.1-alpha bash -uc 'bar=(); echo
"${bar[@]}' # succeeds, but this is already consistent with bash 4.4 and
5.0. So this is expected to succeed.
docker run -it --rm bash:5.1-alpha bash -uc 'bar=(); echo
"${bar[@]+set}' # echos nothing, but this is already consistent with bash
3.2 and 5.0. So this is expected behavior
docker run -it --rm bash:5.1-alpha bash -uc 'bar=(); echo "${bar}'
# fails, but this is already consistent with bash 4.4 and 5.0. So this is
expected to fail, there is no 0th element to the array.
docker run -it --rm bash:5.1-alpha bash -uc 'bar=(); echo
"${bar+set}' # echos nothing, but this is already consistent with bash 3.2
and 5.0. So this is expected behavior
Thanks
Back to gnu.bash.bug | Previous | Next | Find similar
Bash parameter transforamtion on empty array triggers unset variable. Andrew Neff <andrew.neff@visionsystemsinc.com> - 2020-08-10 17:52 -0400
csiph-web