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
Status: RESOLVED FIXED
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
URL: https://lists.gnu.org/archive/html/bu...
Whiteboard:
Keywords:
Depends on:
Blocks: 676268
  Show dependency tree
 
Reported: 2019-01-26 20:14 UTC by Alexander Tsoy
Modified: 2020-04-28 14:33 UTC (History)
0 users

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


Attachments
test.sh (test2.sh,168 bytes, text/plain)
2019-01-26 20:14 UTC, Alexander Tsoy
Details

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]
test.sh

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 test.sh 
foo: bye bye
bar: hello world
$ bash test2.sh 
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?

https://lists.gnu.org/mailman/listinfo/bug-bash
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?)
https://lists.gnu.org/archive/html/bug-bash/2019-01/msg00262.html
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?)
> https://lists.gnu.org/archive/html/bug-bash/2019-01/msg00262.html

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:
---
#!/bin/sh
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):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=94f68f9a36e6771e06bc39ad0286121e8956121c

commit 94f68f9a36e6771e06bc39ad0286121e8956121c
Author:     Lars Wendler <polynomial-c@gentoo.org>
AuthorDate: 2019-03-20 18:24:48 +0000
Commit:     Lars Wendler <polynomial-c@gentoo.org>
CommitDate: 2019-03-20 18:25:08 +0000

    app-shells/bash: Attempt to fix variable scoping in POSIX mode.
    
    Bug: https://bugs.gentoo.org/676344
    Package-Manager: Portage-2.3.62, Repoman-2.3.12
    Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>

 app-shells/bash/bash-5.0_p3-r1.ebuild              | 267 +++++++++++++++++++++
 .../bash-5.0-assignment-preceding-builtin.patch    |  83 +++++++
 2 files changed, 350 insertions(+)
Comment 7 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2020-04-28 14:33:05 UTC
No more input. Assuming it being fixed with current bash-5.0 patch releases.