bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: break no longer breaks out of loops defined in an outer context


From: Stephane Chazelas
Subject: Re: break no longer breaks out of loops defined in an outer context
Date: Wed, 1 Mar 2017 21:58:00 +0000
User-agent: Mutt/1.5.24 (2015-08-30)

2017-03-01 09:49:52 -0500, Chet Ramey:
[...]
> > Would you recommend people start adding:
> > 
> > shopt -s compat44 2> /dev/null || true
> > 
> > at the start of their script that they develop for bash-4.4 now
> > so that it still works even when bash-6.0 makes a non-backward
> > compatible change?
> 
> I know this isn't a serious question, but I'll answer it anyway.
> No. People should look at the effects of each compatibiity version
> option and decide for themselves.
> 
> > 
> > It seems there's a compatXX option for each of the versions
> > since bash31. Will you keep doing it for every version?
> 
> Most likely, but I will probably phase out the shopt options in
> favor of BASH_COMPAT.
[...]

Thanks,

I wasn't aware of BASH_COMPAT. So instead of

shopt -s compat44 2> /dev/null || true

I could use:

BASH_COMPAT=4.4

except that it gives a
bash: BASH_COMPAT: 4.4: compatibility value out of range

If run from an older version of bash (note that it does not set
$? to non-zero nor triggers "set -e").

It seems I would want to specify the lowest version of bash I
want to support in the script. Which makes sense.

BTW, there seems to have been a regression in the handling of the -O
option to the bash interpreter:

$ ./bash -O compat31 -c 'echo "$BASH_VERSION"; [[ a =~ "." ]] && echo yes'
4.4.12(4)-maint
$ ./bash  -c 'echo "$BASH_VERSION"; shopt -s compat31; [[ a =~ "." ]] && echo 
yes'
4.4.12(4)-maint
yes

Was OK with 4.3:

$ bash -O compat31 -c 'echo "$BASH_VERSION"; [[ a =~ "." ]] && echo yes'
4.3.46(1)-release
yes


(affects at least compat43 as well, not failglob for instance).

-- 
Stephane



reply via email to

[Prev in Thread] Current Thread [Next in Thread]