Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 676344 - app-shells/bash-5.0: posix-mode problem with variable scoping
Summary: app-shells/bash-5.0: posix-mode problem with variable scoping
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
Depends on:
Blocks: 676268
  Show dependency tree
Reported: 2019-01-26 20:14 UTC by Alexander Tsoy
Modified: 2019-03-20 18:25 UTC (History)
0 users

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

Attachments (,168 bytes, text/plain)
2019-01-26 20:14 UTC, Alexander Tsoy

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Tsoy 2019-01-26 20:14:50 UTC
Created attachment 562926 [details]

There is some weird problem in posix-mode with variable scoping when creating variables from assignment statements preceding function calls. See attached test case.

$ bash --posix 
foo: bye bye
bar: hello world
$ bash 
foo: hello world
bar: hello world

This bug currently breaks dracut.
Comment 1 Mike Gilbert gentoo-dev 2019-01-27 02:47:50 UTC
Could you report this to the bash bugs list?
Comment 2 Alexander Tsoy 2019-01-28 19:33:26 UTC
Upstream said that this behaviour will not change until next version of bash (bash-5.1?)
Comment 3 Mike Gilbert gentoo-dev 2019-01-28 20:19:59 UTC
Sounds like dracut will need to work around this then.
Comment 4 Ulenrich 2019-03-15 16:48:47 UTC
(In reply to Alexander Tsoy from comment #2)
> Upstream said that this behaviour will not change until next version of bash
> (bash-5.1?)

His answer terrorfied me: 
Clearly you shouldn't use bash --posix mode in a nuclear power grid. By the way: 
Why does't it error out early, when seeing an undefined posix "local" ? 
Or is it a common commenting feature to ignore it, when there is something unidentified, like for example:
Holy_Shit_just_saying myvar=something
Comment 5 Ulenrich 2019-03-15 16:53:31 UTC
No, it is not a commenting feature:
test: line 8: Holy_Shit_just_saying: command not found
foo: hello world
bar: hello world
Comment 6 Larry the Git Cow gentoo-dev 2019-03-20 18:25:15 UTC
The bug has been referenced in the following commit(s):

commit 94f68f9a36e6771e06bc39ad0286121e8956121c
Author:     Lars Wendler <>
AuthorDate: 2019-03-20 18:24:48 +0000
Commit:     Lars Wendler <>
CommitDate: 2019-03-20 18:25:08 +0000

    app-shells/bash: Attempt to fix variable scoping in POSIX mode.
    Package-Manager: Portage-2.3.62, Repoman-2.3.12
    Signed-off-by: Lars Wendler <>

 app-shells/bash/bash-5.0_p3-r1.ebuild              | 267 +++++++++++++++++++++
 .../bash-5.0-assignment-preceding-builtin.patch    |  83 +++++++
 2 files changed, 350 insertions(+)