[Bug 854679] New: bash does not properly handle value assignment in scripts if variable is assigned new value in a while loop
https://bugzilla.novell.com/show_bug.cgi?id=854679 https://bugzilla.novell.com/show_bug.cgi?id=854679#c0 Summary: bash does not properly handle value assignment in scripts if variable is assigned new value in a while loop Classification: openSUSE Product: openSUSE 12.3 Version: Final Platform: x86-64 OS/Version: openSUSE 12.3 Status: NEW Severity: Major Priority: P5 - None Component: Basesystem AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: rens.groenewegen@xs4all.nl QAContact: qa-bugs@suse.de Found By: --- Blocker: --- Created an attachment (id=571071) --> (http://bugzilla.novell.com/attachment.cgi?id=571071) two scripts showing the difference between bash and ksh User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0 if a export someval=0 is done, and someval is assigned a new value in a while [ ] .... do someval=10 done the value of someval will still be 0 instead of 10. ksh does assign a value 10 to someval and retains it after exiting the while loop. see sample scripts. Reproducible: Always Steps to Reproduce: 1.run scripts bashbug and kshnobug 2.notice difference 3.scratch behind ear (left or right, at your discretion) Actual Results: value should have been 10, is still zero (bashbug script) Expected Results: value should have been 10. output of the two scripts: ____________ bashbug ______________ cval before while is now 0 entering while cval = 1 file = 7z cval = 2 file = 7za cval = 3 file = Backarrow2BackSpace cval = 4 file = Backarrow2Delete cval = 5 file = ChangeSymlinks cval = 6 file = Convert cval = 7 file = LinuxVNC cval = 8 file = Mail cval = 9 file = PTBatcher cval = 10 file = PTBatcherGUI after while: cval = 0 ____________ kshnobug ______________ cval before while is now 0 entering while cval = 1 file = 7z cval = 2 file = 7za cval = 3 file = Backarrow2BackSpace cval = 4 file = Backarrow2Delete cval = 5 file = ChangeSymlinks cval = 6 file = Convert cval = 7 file = LinuxVNC cval = 8 file = Mail cval = 9 file = PTBatcher cval = 10 file = PTBatcherGUI after while: cval = 10 -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=854679 https://bugzilla.novell.com/show_bug.cgi?id=854679#c1 --- Comment #1 from rens groenewegen <rens.groenewegen@xs4all.nl> 2013-12-10 15:05:49 UTC --- debian 7 has the same issue with bash, so this is not a suse only bug..... -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=854679 https://bugzilla.novell.com/show_bug.cgi?id=854679#c zhang jiajun <jzhang@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jzhang@suse.com AssignedTo|bnc-team-screening@forge.pr |werner@suse.com |ovo.novell.com | -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=854679 https://bugzilla.novell.com/show_bug.cgi?id=854679#c2 Dr. Werner Fink <werner@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #2 from Dr. Werner Fink <werner@suse.com> 2013-12-12 07:05:21 UTC --- (In reply to comment #1) No bug as this is common behaviour of upstream bash. Tht is if your are using a pipe like this echo xxx | read line echo $line then the result is empty due to the fact that the `read line' is within a real subshell and you never get back a result from a forked subshell. Using a named fifo in bash but not sh scripts will work read line < <(echo xxx) echo $line If you think this is a bug you may use the command bashbug but IMHO you will be informed with the same statement and a n'hint of the bash FAQ like http://mywiki.wooledge.org/BashFAQ/024 -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=854679 https://bugzilla.novell.com/show_bug.cgi?id=854679#c3 --- Comment #3 from rens groenewegen <rens.groenewegen@xs4all.nl> 2013-12-23 13:15:59 UTC --- fine with me to close this, but then "we" agree that the logic of bash semantics and the language definition is flawed in it's core. there is no other major programming language that would come up with the same nonsensical handling and end result in such a bread and butter while loop.... I think after this explanation we may conclude that it is a major bug between the ears of the upstream folk if they think this should be bash's behavior. thanks anyway, best regards Rens -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@novell.com