Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
The fix for 1072086 introduces at least two bugs (that I know of).
Maybe more.
Regression #1:
========== ==
If you have "set -x" turned on, and then redirect the stderr of some
command into a file, the output file to which only the command's stderr
should have been redirected now contains the trace data that should have
gone to the script's stderr instead of the comand's stderr. Here, it's
easier to show than describe:
0 vm38(ROOT)/root ### rpm -q mksh
mksh-39-9.el6.x86_64
0 vm38(ROOT)/root ### cat /tmp/dummy
#!/bin/mksh
set -x
echo Yadda. > /tmp/yadda 2>&1
0 vm38(ROOT)/root ### /tmp/dummy ; echo ======================== ; cat /tmp/yadda
+ echo Yadda.
+ > /tmp/yadda
+ 2>&1
========================
Yadda.
0 vm38(ROOT)/root ###
Now, that's working more or less how I'd expect with the previous
version of mksh. Here's what happens with the new version:
0 vm38(ROOT)/root ### rpm -q mksh
mksh-39-10.el6.x86_64
0 vm38(ROOT)/root ### /tmp/dummy ; echo ======================== ; cat /tmp/yadda
+ > /tmp/yadda
+ 2>&1
========================
+ echo Yadda.
Yadda.
0 vm38(ROOT)/root ###
Note the "+ echo Yadda." ended up in the command's stderr instead of the
script's stderr.
Regression #2:
========== ==
I think this is probably the real problem, and the above is just an
alternate manifestation of the same thing. When I take the redirection
of stderr out of the script:
0 vm38(ROOT)/root ### rpm -q mksh
mksh-39-10.el6.x86_64
0 vm38(ROOT)/root ### cat /tmp/dummy
#!/bin/mksh
set -x
echo Yadda. > /tmp/yadda
0 vm38(ROOT)/root ### /tmp/dummy ; echo ======================== ; cat /tmp/yadda
+ > /tmp/yadda
+ echo Yadda.
========================
Yadda.
0 vm38(ROOT)/root ###
Note the order of the two trace lines. Here's what it used to do:
0 vm38(ROOT)/root ### rpm -q mksh
mksh-39-9.el6.x86_64
0 vm38(ROOT)/root ### /tmp/dummy ; echo ======================== ; cat /tmp/yadda
+ echo Yadda.
+ > /tmp/yadda
========================
Yadda.
0 vm38(ROOT)/root ###
The command used to come out before the redirection, now it's the
other way around. If I'd have it my way, they'd all be on one line,
but meh, the wole world doesn't cater to me. Anyway, I can see that
causing major confusion. I suspect, though, that the two problems
are related. I'm thinking that by getting them out of order like that,
we managed to also generate the trace output after setting up stdout
and stderr redirection for commands.
Version-Release number of selected component (if applicable):
mksh-39-10.el6
How reproducible:
Every time.
Steps to Reproduce:
(see above)
Actual results:
(see above)
Expected results:
(see above)
1st regression. That's an issue, as this should not happen.
2nd regression - it's a change, but is it a bug? I agree, that it would be nice to have it on one line. This change was backported from newer upstream releases and its how mksh behaves since version 47 (+-4 years ago). Technically, the redirection does happen before command is executed so when comparing before/after, the before version seems more correct. Also, I've checked posix and afaik it does not seem it contradicts anything.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHBA-2018:1912