Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 636652 - [Future EAPI] Update Bash version to 5.0
Summary: [Future EAPI] Update Bash version to 5.0
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: PMS/EAPI (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: PMS/EAPI
URL:
Whiteboard: in-eapi-8
Keywords:
: 780009 (view as bug list)
Depends on:
Blocks: future-eapi
  Show dependency tree
 
Reported: 2017-11-05 18:32 UTC by Ulrich Müller
Modified: 2021-06-13 20:36 UTC (History)
8 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
PMS patch (0001-EAPI-7-Bash-version-is-4.3.patch,1.84 KB, patch)
2017-11-05 18:32 UTC, Ulrich Müller
Details | Diff
Ban nameref variables from exported and default scope (0001-Ban-nameref-variables-from-exported-and-default-scop.patch,1.85 KB, patch)
2021-05-25 16:20 UTC, Ulrich Müller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Müller gentoo-dev 2017-11-05 18:32:11 UTC
Created attachment 502746 [details, diff]
PMS patch

Bash 4.3 is stable everywhere, so we could update the Bash version in EAPI 7.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2017-11-05 18:38:40 UTC
Does this version bring anything useful in? If not, then I think switching bash versions for the sake of it is only going to add more EAPI differences for no benefit.
Comment 2 Arfrever Frehtes Taifersar Arahesis 2017-11-05 19:16:45 UTC
Some potentially useful features added in BASH 4.3:

    The shell has `nameref' variables and new -n(/+n) options to declare and
    unset to use them, and a `test -R' option to test for them.

    The shell now allows assigning, referencing, and unsetting elements of
    indexed arrays using negative subscripts (a[-1]=2, echo ${a[-1]}) which
    count back from the last element of the array.

    The {x}<word redirection feature now allows words like {array[ind]} and
    can use variables with special meanings to the shell (e.g., BASH_XTRACEFD).

    The test/[/[[ `-v variable' binary operator now understands array
    references.
Comment 3 Ulrich Müller gentoo-dev 2017-11-05 19:33:42 UTC
I don't think that list includes any "killer feature" but IMHO we shouldn't fall too much behind the current version.

We could skip 4.3 of course and go for 4.4 (or later) in a future EAPI instead.
Comment 4 Ulrich Müller gentoo-dev 2018-04-14 10:40:23 UTC
This has been rejected by the council in its 2017-11-12 meeting:
https://projects.gentoo.org/council/meeting-logs/20171112-summary.txt

Closing.
Comment 5 Ulrich Müller gentoo-dev 2019-05-26 10:44:14 UTC
Reopening for bash-4.4 (or 5.0). IMHO, the following feature of bash-4.4 would be  of particular interest. For example, it allows assigning the output of find -print0 to an array:

d.  The `mapfile' builtin now has a -d option to use an arbitrary character
    as the record delimiter, and a -t option  to strip the delimiter as
    supplied with -d.
Comment 6 Ulrich Müller gentoo-dev 2020-02-20 12:55:32 UTC
We may also want to require that the standard variables defined in chapter 7 must not be named references (declare -n), because this would cause issues for tests and presumably also for environment saving.

https://projects.gentoo.org/pms/7/pms.html#x1-590007
Comment 7 Ulrich Müller gentoo-dev 2020-10-25 23:44:25 UTC
Bash 5.0 is stable since a long time, so I believe that we should go for this version.
Comment 8 Ulrich Müller gentoo-dev 2021-04-05 11:17:38 UTC
*** Bug 780009 has been marked as a duplicate of this bug. ***
Comment 9 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-05-16 05:34:57 UTC
As discussed in #gentoo-pms, depending on how quick progress is with implementation, we may now want to consider Bash 5.1 given it has recently been marked stable in Gentoo.

There are no real new features relevant to us (other than perhaps negative array indices):

>x.  The shell now allows assigning, referencing, and unsetting elements of
>    indexed arrays using negative subscripts (a[-1]=2, echo ${a[-1]}) which
>    count back from the last element of the array.

(Note that it contains stricter parsing of parameter expansion which caused a few ebuilds (see bug 762394) to stop working with 5.1, but they were in the wrong anyway.)
Comment 10 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-05-16 07:56:26 UTC
(In reply to Sam James from comment #9)
> As discussed in #gentoo-pms, depending on how quick progress is with
> implementation, we may now want to consider Bash 5.1 given it has recently
> been marked stable in Gentoo.

I have mixed feelings about this.  With bash 5.1 requiring readline 8.1 which in turn broke a lot of stuff I'd rather remain on the safe side here.

> 
> There are no real new features relevant to us (other than perhaps negative
> array indices):
> 
> >x.  The shell now allows assigning, referencing, and unsetting elements of
> >    indexed arrays using negative subscripts (a[-1]=2, echo ${a[-1]}) which
> >    count back from the last element of the array.

That one's from 4.3.
Comment 11 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-05-16 08:00:53 UTC
(In reply to Michał Górny from comment #10)
> (In reply to Sam James from comment #9)
> > As discussed in #gentoo-pms, depending on how quick progress is with
> > implementation, we may now want to consider Bash 5.1 given it has recently
> > been marked stable in Gentoo.
> 
> I have mixed feelings about this.  With bash 5.1 requiring readline 8.1
> which in turn broke a lot of stuff I'd rather remain on the safe side here.
> 

I don't feel strongly about it here either way.

> > 
> > There are no real new features relevant to us (other than perhaps negative
> > array indices):
> > 
> > >x.  The shell now allows assigning, referencing, and unsetting elements of
> > >    indexed arrays using negative subscripts (a[-1]=2, echo ${a[-1]}) which
> > >    count back from the last element of the array.
> 
> That one's from 4.3.

Oh, ugh. I see now.
Comment 12 Larry the Git Cow gentoo-dev 2021-05-24 04:37:20 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=fc728f5d4ab0dd58ef9cd940397a8990bb066d15

commit fc728f5d4ab0dd58ef9cd940397a8990bb066d15
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2021-05-12 12:26:32 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2021-05-24 04:36:45 +0000

    Require bash-5.0 in EAPI 8
    
    Bug: https://bugs.gentoo.org/636652
    Signed-off-by: Michał Górny <mgorny@gentoo.org>
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 bin/eapi.sh   | 6 +++++-
 bin/ebuild.sh | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)
Comment 13 Ulrich Müller gentoo-dev 2021-05-24 09:17:10 UTC
(In reply to Ulrich Müller from comment #6)
> We may also want to require that the standard variables defined in chapter 7
> must not be named references (declare -n), because this would cause issues
> for tests and presumably also for environment saving.
> 
> https://projects.gentoo.org/pms/7/pms.html#x1-590007

Omitting this for now, unless I would get feedback that it leads to problems with the implementation otherwise.
Comment 14 Ulrich Müller gentoo-dev 2021-05-25 16:20:46 UTC
Created attachment 711207 [details, diff]
Ban nameref variables from exported and default scope

(In reply to Ulrich Müller from comment #13)
> > We may also want to require that the standard variables defined in chapter 7
> > must not be named references (declare -n), because this would cause issues
> > for tests and presumably also for environment saving.
> > 
> > https://projects.gentoo.org/pms/7/pms.html#x1-590007
> 
> Omitting this for now, unless I would get feedback that it leads to problems
> with the implementation otherwise.

So, nameref variables will break detection of bash arrays. For example, the default src_prepare() has this test:

    [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]

If PATCHES is a name reference and its target is an array, then declare -p will _not_ resolve the indirection, but output "declare -n" instead.

We could work around this by updating the test to:

    ( unset "PATCHES[1]" 2>/dev/null )

using the fact that unset will return an error status when applied to an element (other than the zeroth) of a scalar variable, and executing it in a subshell so that the original array won't be affected. However, this looks like a very hackish solution which could break with future Bash versions.

Therefore, ban nameref variables from exported and default scope.
Comment 15 Ulrich Müller gentoo-dev 2021-05-25 16:21:37 UTC
> Created attachment 711207 [details, diff] [details, diff]
> Ban nameref variables from exported and default scope

Please review.
Comment 16 Ulrich Müller gentoo-dev 2021-05-25 20:14:39 UTC
(In reply to Ulrich Müller from comment #14)

As a matter of fact, bash-4.4 introduced a new @ operator in parameter expansion. So testing whether a variable is an array is now as simple as:

    [[ ${PATCHES@a} == *a* ]]
Comment 17 Larry the Git Cow gentoo-dev 2021-06-13 19:18:54 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/pms.git/commit/?id=3f93cb5890b64d642a68aafa3997abe9dda46a10

commit 3f93cb5890b64d642a68aafa3997abe9dda46a10
Author:     Ulrich Müller <ulm@gentoo.org>
AuthorDate: 2021-05-25 15:59:13 +0000
Commit:     Ulrich Müller <ulm@gentoo.org>
CommitDate: 2021-06-05 08:55:34 +0000

    Ban nameref variables from exported and default scope
    
    Bug: https://bugs.gentoo.org/636652
    Signed-off-by: Ulrich Müller <ulm@gentoo.org>

 ebuild-format.tex | 2 ++
 1 file changed, 2 insertions(+)

https://gitweb.gentoo.org/proj/pms.git/commit/?id=3b55b43b16c79e90af9cd99e9a71e469b988922a

commit 3b55b43b16c79e90af9cd99e9a71e469b988922a
Author:     Ulrich Müller <ulm@gentoo.org>
AuthorDate: 2017-11-05 18:04:28 +0000
Commit:     Ulrich Müller <ulm@gentoo.org>
CommitDate: 2021-06-05 08:55:34 +0000

    EAPI 8: Bash version is 5.0
    
    Bug: https://bugs.gentoo.org/636652
    Signed-off-by: Ulrich Müller <ulm@gentoo.org>

 eapi-differences.tex | 3 ++-
 ebuild-format.tex    | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)