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


Groups > gnu.bash.bug > #14415

Re: delcare -a on a nameref in a function modifies nameref instead of target

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: delcare -a on a nameref in a function modifies nameref instead of target
Date Sun, 29 Jul 2018 16:04:25 -0400
Lines 31
Approved bug-bash@gnu.org
Message-ID <mailman.4394.1532894682.1292.bug-bash@gnu.org> (permalink)
References <CAMu=BrqTimtENjRABPgRdDhn5bQG2zBMv5YfQsNQDETh6oAjeQ@mail.gmail.com> <CAMu=Brq3CfiUWmauM8n=MYHeaWSywE5_sEJzBd0ET3SrrB+1KA@mail.gmail.com> <ae9ccdae-89e3-388b-d6e5-e1ce6cd914dd@case.edu>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
X-Trace usenet.stanford.edu 1532894682 1096 208.118.235.17 (29 Jul 2018 20:04:42 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=RRD4Jr+3F19ZSGUZ91MIot54DwGJBbwAMzNr3KaG8SI=; b=XK+pRRU/uG/uThlGA5CS5mzv1A9RpM+oQ9zmLKJp3IIRqw5faRY8qYWH0iZSghAcTN N4eoQU4NaBUSumhwyXTmsjk4M5B9EFO4+htDS4klBnIh1AlUF5vZC2WreLehi2ZGNK4v V86C3o+fxt88dWBuxLvvhIQsSfQYzpcoSYLU+mTBtJy4SewXSaC8DsBC4+M0XF/zLE/i axIoPjaa/4tXxjOEoy80CWv/wjjNDJ09cCzivRed01SZokbICkreIOI+s4VltL7xSm9s TUBrLxMaMly77wF7uhNdiEMD5novh8G1sNvwjAz6a3xxc6cpz0SRWky44MbhDznkeoui pyGw==
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=RRD4Jr+3F19ZSGUZ91MIot54DwGJBbwAMzNr3KaG8SI=; b=jhqPwtTT3cxR85cdt4aK6s5gnoL3X64OSfCtI52jJaakuo53Fix1XGYA9cHdybq/eU SrPaGTc36V5hh5Rl7JyNcOwBhiu8CsUhnA5jNLLJ6kiAENqDOJ/QOhS3ctGBUXQMuxaU ewZ/gPrhxSWN7fgRDQvTvACwjYRfIc+qqp03esshyKB8ksYDUpX1qrjj2CbZmhkFMACz S1Ff0MVdo7aNHDFFOzu0tUktAU9hXZr1ePXmGcH/Xl55MWJEq2ZRtJD6sOCDloyinJdY Uj3HR4VcuKj6vpS3abkjoplxFX/RazL4S294bxGNWVgo1JLgstNXJqf0ZOZhxn4eeMDF Wm+Q==
X-Gm-Message-State AOUpUlFv2Urgw/g4FBejg6zhDqEE9Rf96wvr6y5FGqqRrxss6xRQe13R fVRzCHThUEauO+YEUpu0GM2NJXuPiG2l5PXBx/I=
X-Google-Smtp-Source AAOMgpdCZjmS5t8Y616xR4BID3WkF3hAoPtLepJmKfHJXOsgogpOVv815whLSBz5Sj5p3uV3Cdfino18oQHz7tWrVns=
X-Received by 2002:a19:b519:: with SMTP id e25-v6mr8277768lff.119.1532894676214; Sun, 29 Jul 2018 13:04:36 -0700 (PDT)
In-Reply-To <ae9ccdae-89e3-388b-d6e5-e1ce6cd914dd@case.edu>
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2a00:1450:4864:20::12a
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:14415

Show key headers only | View raw


I think there's a related regression in the latest devel commit. Creating a
local variable with the same name as a higher-scoped nameref pointing to an
unset variable creates a local variable with the name of the target of the
nameref.

Starting with:

    declare -n ref=var
    f() { local ref=Y; declare -p ref var; local; }

This still works fine in both latest and previous:

    $ var=X; f
    declare -- ref="Y"
    declare -- var="X"
    ref=Y

But the behavior in the unset target case changed from the expected:

    $ unset var; f
    declare -- ref="Y"
    bash: declare: var: not found
    ref=Y

to:

    $ unset var; f
    declare -n ref="var"
    declare -- var="Y"
    var=Y

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


Thread

Re: delcare -a on a nameref in a function modifies nameref instead of target Grisha Levit <grishalevit@gmail.com> - 2018-07-29 16:04 -0400

csiph-web