Gentoo Archives: gentoo-dev

From: Mike Frysinger <vapier@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] utilizing BASH_COMPAT to smooth upgrades
Date: Tue, 20 Oct 2015 22:51:15
Message-Id: 20151020225104.GK3918@vapier.lan
In Reply to: Re: [gentoo-dev] utilizing BASH_COMPAT to smooth upgrades by Ulrich Mueller
1 On 21 Oct 2015 00:03, Ulrich Mueller wrote:
2 > >>>>> On Tue, 20 Oct 2015, Mike Frysinger wrote:
3 >
4 > >> EAPI 6: Bash version is 4.2.
5 >
6 > > do we want to mandate the BASH_COMPAT aspect in PMS ?
7 > > or at least make into a recommendation ?
8 >
9 > If I understand [1] correctly, coverage of BASH_COMPAT is incomplete:
10 > It only changes incompatible behaviour back to the old version, but it
11 > won't disallow using new features.
12
13 correct. it would help when code changes behavior like when =~ changed quoting
14 behavior and we had to scramble to tweak its usage throughout the tree (although
15 it was more external programs than eclasses/ebuilds). but if you're running
16 bash-4.3, setting BASH_COMPAT=4.2 would not keep code from using things like
17 ${VAR^^}.
18
19 > Therefore I'd make it a recommendation at most. Something along the
20 > lines of: "The interpreter is assumed to be GNU bash, version as
21 > listed in table xyz, or any later version. If possible, the package
22 > manager should set the shell's compatibility level to the exact
23 > version specified."
24
25 and include the recommended snippet as well as add a warning about not exporting
26 the variable less it break external shell scripts.
27
28 > > https://bugs.gentoo.org/431340#c20
29 > > local maj=4 min=2
30 > > if ([[ ${BASH_VERSINFO[0]} -lt ${maj} ]] ||
31 > > [[ ${BASH_VERSINFO[0]} -eq ${maj} && ${BASH_VERSINFO[1]} -lt ${min ]]) ; then
32 >
33 > Why the subshell here?
34
35 it can be dropped. was purely for grouping/line wrapping, but || gets you that.
36 -mike

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies