Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Koichi Murase Newsgroups: gnu.bash.bug Subject: Re: Incorrect / Inconsistent behavior with nameref assignments in functions Date: Sat, 29 Aug 2020 08:46:27 +0900 Lines: 41 Approved: bug-bash@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: usenet.stanford.edu 1598658404 25146 209.51.188.17 (28 Aug 2020 23:46:44 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash@gnu.org, bash@packages.debian.org To: Binarus 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=Q0r7i6FbXWrRRI4KImF9kCerIVao1WvgDqTDXqIH4z4=; b=X6J017yGCdwPgsfvcQPlDAP3qtlcOPcqehA7+RFE/gRbHYZi4eJ51ARRbmMl5158E5 D52m2327QPDtSycgtd2c6yzo1wrE4GRjiaqdQ7vkvc2KiyM8QW7mTsMbbqghxr3KvtOW QcYPGubkywmNXv+WPdxtsfsokydM/M/yexkB6NQCcuLGmYRaNl5YeszwWxz6cAX3AIoD hsWG8tXwGv4RLpL+IaIQMBK7/JLc5mTbjvHAHrgqiz6VP4Y5edGLlhMOZGAtbe0lanPJ CUvpBnHqsBDdrflxUT7isEIAarePAtjzE5EdD7oJxo6JCWVcGGEpunSC8R7/km60eQyi +z8A== 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=Q0r7i6FbXWrRRI4KImF9kCerIVao1WvgDqTDXqIH4z4=; b=eKiu4BZgomyGjWNJkAOK17wugp/2hUjDiuszbIFFzD5pc1O+dG+vzkLfQyqhEfreUO I1hwijcVMpa1PRWBN72q1ePMKb0wbFXk71ltwNdiadi47wOSmiOD0rNkgqvtKO1vKy5i PYcXnUNwOE43ZNjG20xHZWlR1kuhjTUuZv4AgzE5EFmkwWJwIzp4Rul4NFEKU5Ieyr8w 99rBkWVNB1gnBsiY4ASD6l9Nj9a2pGMSiYGATmJy4ykWyAmLskniOdkS5PtQzbW1/HTO k9uVlm1PQ9bBWX6nhNfEXi7bSJUO7UVvqpK0C21tbaFQGtTLwSYlyzB3ndJaNI1gRTau mEsQ== X-Gm-Message-State: AOAM5307e/r9f+vLRSFOVIDUQvEUOLnIxerNqB1y1TEtf14r71IxJxBs fuy8cpGfdMYvLEDRyUSfPzbmiRlE9fhlfyf7Ft4= X-Google-Smtp-Source: ABdhPJxE5qUdn7FVRUk6HHNSTwp7FJ7tvn9uTmwoVg6T70Tl/BVQmXJIuQqzSAzm6K2WYpFxTYhIf8OqIuG3WrKKtkk= X-Received: by 2002:a17:906:3789:: with SMTP id n9mr168861ejc.389.1598658399258; Fri, 28 Aug 2020 16:46:39 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::642; envelope-from=myoga.murase@gmail.com; helo=mail-ej1-x642.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, 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-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: X-Mailman-Original-References: Xref: csiph.com gnu.bash.bug:16837 2020-08-28 22:04 Binarus : > Description: > ------------ > > Under certain circumstances, assignments of namerefs to local variables > in functions behaves in a way which makes namerefs completely useless. > Furthermore, the behavior is not consistent. This is actually not related to namerefs and has already been fixed in Bash 5.1 and the devel branch. Think about the following codes: a=1; f1() { local a=$a; local; }; f1 a=2; f2() { local -a a=("$a"); local; }; f2 The results for `f1' are the same for all the Bash versions 2.0..devel, but the results for `f2' varies in versions. Here is the summary of the results from the different versions of Bash: - 2.0..3.0: f1: a=1, f2: a=([0]="1") - 3.1: f2: a=1, f2: a=([0]="") - 3.2..4.2: f1: a=1, f2: a=([0]="1") - 4.3..5.0: f1: a=1, f2: a=([0]="") - 5.1..dev: f1: a=1, f2: a=([0]="1") I checked the detailed changes. The behavior of `f2' in 3.1 was reported as a bug in the following thread. https://lists.gnu.org/archive/html/bug-bash/2006-05/msg00025.html It was fixed in 8b35878f (commit bash-20060504 snapshot). However, the bug seems to be introduced again in 36eb585c (commit bash-20121221 snapshot). This regression has been reported at https://savannah.gnu.org/support/index.php?109669 Finally, it was again fixed in c6c7ae81 (commit bash-20200427 snapshot). -- Koichi