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


Groups > gnu.bash.bug > #14368

Re: temp env allows variables that look like array subscripts

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Grisha Levit <grishalevit@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: temp env allows variables that look like array subscripts
Date Thu, 19 Jul 2018 15:02:12 -0400
Lines 28
Approved bug-bash@gnu.org
Message-ID <mailman.3840.1532026949.1292.bug-bash@gnu.org> (permalink)
References <CAMu=Brp=7yuZwb5qa-ymLWsuS=N0qyQvR7KopO5vfZTm==DM8Q@mail.gmail.com> <38b37862-1f2b-fb34-6ab6-8cd6c9439908@case.edu>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
X-Trace usenet.stanford.edu 1532026950 14829 208.118.235.17 (19 Jul 2018 19:02:30 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash <bug-bash@gnu.org>
To Chester Ramey <chet.ramey@case.edu>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=haXD3tF52H99Uko7wrhYcFqMyjY1AMehyxafnNjut5M=; b=TOel5iCy/AmuCogpBgGugWirUamEgCVXLZiP5izSKTcJHFs1WzVb0apbhiYTEo/4iv d40AuQkyKnbRGpB1YnsmI7pUgMj5GfyTCt5QHR3QQ8/p7ooN5vBV0Gtl2nExnm5McwiE 0YlOomyPxfY8RgPgl7gUI0iAf4KemijB+QmrDzgvl9RC+rmvq1QHXtiCOs6w3CkPXlzj e21M3Vkz/4Tw29a2V2snCajRxoveXKvfoVwYOEwAXYLKqaUMBZZiSyszaqOCjQhmTd7+ xYbcyAPk56k6zzBVGCaUQFyJq6I4XbvWX51gZ6x/ruzJYOOOERMOK7Bl8jD42XV9sE7T ebvA==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=haXD3tF52H99Uko7wrhYcFqMyjY1AMehyxafnNjut5M=; b=J82iNa5SLBEVvppPJ/Jc0aytK2UkEJBQzEUJLZeGjKJxeoRwAfSgNuuNdDXTLjQ8yU tytnlqTj1/thDBqvo0wz29uv3ik0q3IpmWCuaAbrf33usMh65/jXhobY9mweV1wr244+ d233wciL9ff5t5/UkuTxfvirGSwPG6oso+R95oCy7FsJ9aKxX8sNkpc7wTI4P+d0H0ul sPJPG7R07PaTN0isLBvj/SbuFw+IO3TMH1YHhW3KI/xr76daWBXPq3pcgz6qpx3hk5ij biIzpWGryqIRJC4mWRdGHU092X/VrJQ4aj9uOhcu795jKDQGa9OuZmP6+MBWPNN9DFzd EMxg==
X-Gm-Message-State AOUpUlFpLTKgtuJjLByO2FUiNtzH9X2n/7GJA3LgqDUhsJTpttOTpGfh 8Tl9KAoCOzolazRQKStlnenFWjFue4nyhD4PsKc=
X-Google-Smtp-Source AAOMgpc44FU9OGh9P0bWl2S/jRyJxudrYTgYQOeYjieG4crNrpX/7rHX3KKIrwDZc5UooCeXEGanEHDVvmm2K4JrSQE=
X-Received by 2002:a19:b519:: with SMTP id e25-v6mr7169368lff.119.1532026944026; Thu, 19 Jul 2018 12:02:24 -0700 (PDT)
In-Reply-To <38b37862-1f2b-fb34-6ab6-8cd6c9439908@case.edu>
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2a00:1450:4864:20::22c
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
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 <http://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>
Xref csiph.com gnu.bash.bug:14368

Show key headers only | View raw


On Wed, Jul 18, 2018 at 11:01 AM Chet Ramey <chet.ramey@case.edu> wrote:
> The question is what to do with them:
>
> 1. Reject them as invalid environment variable names.
>
> 2. Accept them as if they were valid assignment statements and create an
>    array variable, rejecting the second assignment because it uses an
>    invalid subscript, even though you can't export environment variables.
>
> 3. Create variables with the names as given, and just put them in the
>    environment of commands invoked by `f', under the principle that POSIX
>    says "applications shall be tolerant of such names [in the
>    environment]f." Of course, that doesn't mean applications have to put
>    garbage into the environment.

I would vote for (1) unless either:

(a) bash supports the rest of array-related assignment syntax in the temporary
environment, in which case (2) sounds better. i.e. it seems like it would be
surprising for `a[0]=X declare -p a' and `a=(X) declare -p a' to produce
different results, with the former creating an array and the latter a string.
or
(b) bash accepts other valid-as-environment-but-not-as-shell-variable names
in the temporary environment, in which case (3) sounds better. i.e. `a[0]'
and `a@0' are both valid environment variable names but neither are valid bash
variable names. It seems surprising that the former would be passed on to
commands but the latter rejected by the parser.

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


Thread

Re: temp env allows variables that look like array subscripts Grisha Levit <grishalevit@gmail.com> - 2018-07-19 15:02 -0400

csiph-web