Path: csiph.com!xmission!news.glorb.com!usenet.stanford.edu!not-for-mail From: Chet Ramey Newsgroups: gnu.bash.bug Subject: Re: updating shopt compat settings to include current version Date: Fri, 16 Oct 2015 11:37:53 -0400 Lines: 113 Approved: bug-bash@gnu.org Message-ID: References: <20151015173433.GS4446@vapier.lan> <561FF051.8000001@case.edu> <20151015192704.GU4446@vapier.lan> <56200730.2060900@case.edu> <20151015213025.GW4446@vapier.lan> Reply-To: chet.ramey@case.edu NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020302020108050504030806" X-Trace: usenet.stanford.edu 1445009896 6136 208.118.235.17 (16 Oct 2015 15:38:16 GMT) X-Complaints-To: action@cs.stanford.edu Cc: chet.ramey@case.edu To: bug-bash@gnu.org, Mike Frysinger Envelope-to: bug-bash@gnu.org X-Enigmail-Draft-Status: N1110 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 In-Reply-To: <20151015213025.GW4446@vapier.lan> X-Junkmail-Status: score=10/60, host=mpv6.cwru.edu X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 129.22.105.36 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:11673 This is a multi-part message in MIME format. --------------020302020108050504030806 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 10/15/15 5:30 PM, Mike Frysinger wrote: > that assumes that behavior changes only once between versions. pretty su re > we've seen changes where bash-3.2 did one thing, bash-4.3 did something e lse, > and versions in between did yet another thing. i don't recall exact exam ples > off the top of my head, but i *feel* like it has happened :). Oh, I'm sure it has. > >>> the bash compat feature seems to address this nicely: our standard says >>> we should use bash-3.2, so we set the compat level to that, and then we >>> have much stronger confidence in newer versions not breaking, or people >>> adding code that only works on newer versions. >> >> You should approach this with caution. I'm sure there are changes and b ug >> fixes that introduce incompatible behavior that are not addressed by the >> compatNN variables. I guess as long as it doesn't bite you, you're ok. > > right. we're OK with reporting & getting those fixed. Sometimes they're not going to be `fixed'. Many times those are really bug fixes or fixes for greater consistency or compatibility. >> I mean, in theory, it's simple to do that: >> >> unset BASH_COMPAT >> shopt -u compat31 >> command shopt -s compat32 2>/dev/null > > ... but that doesn't work in bash-3.2: > $ bash-3.2 -c 'shopt -s compat32' > bash-3.2: line 0: shopt: compat32: invalid shell option name No, it really does. That's why I redirected the output to /dev/null. If you run with `set -e' enabled, you can follow it with `|| :'. Running those commands leaves shell_compatibility_level == 32 on all existing versions of bash >= bash-3.2. The trick is that on bash-3.2, unsetting compat31 sets the shell compatibility level to 32, so the failed attempt to set compat32 doesn't make a difference. > and it won't work when we updated to bash-4.2/4.3, or when you stop addin g > new compatXY options. No, it really will. Even if and when I take out the compatNN options, unsetting BASH_COMPAT and setting it appropriately should do the trick. If you want to make, say, bash-4.2 your minimum version, you will first have to check ${BASH_VERSINFO[0]} and ${BASH_VERSINFO[1]} anyway to identify bash versions that you want to reject. Then you can use unset BASH_COMPAT shopt -u compat31 compat32 compat40 compat41 shopt -s compat42 2>/dev/null || : to set shell_compatibility_level to 42 on bash versions >= bash-4.2. (this needs the attached patch for bash-4.3 to fix a typo in shopt.def) Chet - -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlYhGcUACgkQu1hp8GTqdKvjxQCdHKmE7Ouzi/ct/XjWqEjnDJrL ahAAniFOB8rGodMhOZb8WSjTjOadlDf8 =lC3l -----END PGP SIGNATURE----- --------------020302020108050504030806 Content-Type: application/x-patch; name="shopt-compat42.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="shopt-compat42.patch" ZGlmZiAtckMgMiBiYXNoLTQuMy40Mi9idWlsdGlucy9zaG9wdC5kZWYgYmFzaC00LjMuNDMv YnVpbHRpbnMvc2hvcHQuZGVmCioqKiBiYXNoLTQuMy40Mi9idWlsdGlucy9zaG9wdC5kZWYJ MjAxMy0wMi0yNyAwOTo0MzoyMC4wMDAwMDAwMDAgLTA1MDAKLS0tIGJhc2gtNC4zLjQzL2J1 aWx0aW5zL3Nob3B0LmRlZgkyMDE1LTEwLTE2IDExOjI1OjI4LjAwMDAwMDAwMCAtMDQwMAoq KioqKioqKioqKioqKioKKioqIDE2MSwxNjUgKioqKgogICAgeyAiY29tcGF0NDAiLCAmc2hv cHRfY29tcGF0NDAsIHNldF9jb21wYXRpYmlsaXR5X2xldmVsIH0sCiAgICB7ICJjb21wYXQ0 MSIsICZzaG9wdF9jb21wYXQ0MSwgc2V0X2NvbXBhdGliaWxpdHlfbGV2ZWwgfSwKISAgIHsg ImNvbXBhdDQyIiwgJnNob3B0X2NvbXBhdDQxLCBzZXRfY29tcGF0aWJpbGl0eV9sZXZlbCB9 LAogICNpZiBkZWZpbmVkIChSRUFETElORSkKICAgIHsgImNvbXBsZXRlX2Z1bGxxdW90ZSIs ICZjb21wbGV0ZV9mdWxscXVvdGUsIChzaG9wdF9zZXRfZnVuY190ICopTlVMTH0sCi0tLSAx NjEsMTY1IC0tLS0KICAgIHsgImNvbXBhdDQwIiwgJnNob3B0X2NvbXBhdDQwLCBzZXRfY29t cGF0aWJpbGl0eV9sZXZlbCB9LAogICAgeyAiY29tcGF0NDEiLCAmc2hvcHRfY29tcGF0NDEs IHNldF9jb21wYXRpYmlsaXR5X2xldmVsIH0sCiEgICB7ICJjb21wYXQ0MiIsICZzaG9wdF9j b21wYXQ0Miwgc2V0X2NvbXBhdGliaWxpdHlfbGV2ZWwgfSwKICAjaWYgZGVmaW5lZCAoUkVB RExJTkUpCiAgICB7ICJjb21wbGV0ZV9mdWxscXVvdGUiLCAmY29tcGxldGVfZnVsbHF1b3Rl LCAoc2hvcHRfc2V0X2Z1bmNfdCAqKU5VTEx9LAo= --------------020302020108050504030806--