Bug 1011642 - Issue with command substitution (#927586)
Issue with command substitution (#927586)
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: ksh (Show other bugs)
6.4
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Siteshwar Vashisht
BaseOS QE - Apps
: Reopened
: 1022589 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-24 13:14 EDT by Timothy Farmer
Modified: 2016-10-20 08:12 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-10-20 08:12:48 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Timothy Farmer 2013-09-24 13:14:47 EDT
Description of problem: When using command substitution everything works as expected as long as you are on a TTY connection. When on a non TTY connection and using command substitution nothing is returned.


Version-Release number of selected component (if applicable): ksh-20100621-19.el6_4.4.x86_64


How reproducible: Extremely


Steps to Reproduce:
1.Execute the following on a non TTY connection as a script

#!/bin/ksh
hostname
echo HOSTNAME=$(hostname)

Actual results:
localhost.localdomain
HOSTNAME=


Expected results:
localhost.localdomain
HOSTNAME=localhost.localdomain

Additional info: This issue is not in ksh-20100621-19.el6_4.3.x86_64
Comment 2 RHEL Product and Program Management 2013-10-13 21:57:05 EDT
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.
Comment 3 Michal Hlavinka 2013-10-23 12:04:32 EDT
*** Bug 1022589 has been marked as a duplicate of this bug. ***
Comment 4 Darroch Royden 2013-11-27 11:46:22 EST
This is also reproducible under RHEL 5.10 with the package: ksh-20100621-18.el5

ksh-20100621-12.el5 does not have the same issue. 

It is intermittent with ksh-20100621-18.el5, example script:

#!/bin/ksh

while [ -n "$(echo hello | grep -v "$(date +%y%m%d)")" ];
do
  ((COUNT += 1))
  if [[ "$COUNT" -gt 1000 ]]; then
    echo here
    break
  fi
done
echo $COUNT

Running the script 10 times, will give you 10 different results of $COUNT. Most of them < 50
Comment 5 Michal Hlavinka 2013-11-28 09:08:41 EST
Please test if you can reproduce this with latest ksh package that we have in rhel6.5: ksh-20120801-10.el6
Comment 6 Darroch Royden 2013-11-28 09:14:07 EST
My issue is under RHEL5.10, rather than RHEL6.x - should I raise a seperate bugzilla id?

ksh-20100621-18.el5 is the latest version for RHEL5.10.
Comment 7 Michal Hlavinka 2013-11-28 09:24:34 EST
(In reply to Darroch Royden from comment #6)
> My issue is under RHEL5.10, rather than RHEL6.x - should I raise a seperate
> bugzilla id?

No need to do this. We already have bug for rhel5. It's bug #1028504, but you won't be able to see it as it is private. My question was for Timothy
Comment 8 Darroch Royden 2013-11-28 10:04:47 EST
Understood - can I be granted access to track its progress and help test solutions?
Comment 9 Michal Hlavinka 2013-11-28 10:09:01 EST
(In reply to Darroch Royden from comment #8)
> Understood - can I be granted access to track its progress and help test
> solutions?

You will have to open support case at http://access.redhat.com/home , then support team can monitor it for you and/or maybe grant you access to that bug.
Comment 10 Michal Hlavinka 2013-12-09 08:06:24 EST
Timothy:
Please test if you can reproduce this with latest ksh package that we have in rhel6.5: ksh-20120801-10.el6 Thank you
Comment 11 Timothy Farmer 2013-12-09 09:18:36 EST
Michal,

I will test as soon as I have an opportunity to. Waiting on a co-worker to give me the go-ahead.
Comment 12 Timothy Farmer 2013-12-09 09:18:55 EST
Michal,

I will test as soon as I have an opportunity to. Waiting on a co-worker to give me the go-ahead.
Comment 13 Timothy Farmer 2013-12-13 18:29:30 EST
This issue is resolved with the latest version.
Comment 14 Timothy Farmer 2014-07-08 11:03:31 EDT
This bug has resurfaced in ksh-20120801-10.el6_5.3.x86_64. We ran a non tty session with the following code

#!/bin/ksh
set -x
hostname=$(hostname)
echo Hostname is ${hostname}
hostname=`hostname`
echo Hostname 2 is ${hostname}

Our output was

+ hostname
+ hostname=''
+ echo Hostname is
Hostname is
+ hostname
+ hostname=server.domain.local
+ echo Hostname 2 is server.domain.local
Hostname 2 is server.domain.local

in a PuTTY session we get the following

+ hostname
+ hostname=server.domain.local
+ echo Hostname is server.domain.local
Hostname is server.domain.local
+ hostname
+ hostname=server.domain.local
+ echo Hostname 2 is server.domain.local
Hostname 2 is server.domain.local
Comment 15 Michal Hlavinka 2014-07-09 11:05:12 EDT
I've tried to reproduce this with latest 6.5.z ~ 2012-08-01-10.el6_5.7 and it works fine. 

I stored the reproducer in test.sh and tried:

./test.sh

ssh localhost `pwd`/test.sh

su - $USER `pwd`/test.sh

and in all three cases it worked. What are your complete reproducer steps, what do you mean by "non tty session" ?
Comment 16 Timothy Farmer 2014-07-09 19:37:26 EDT
Running the script through a non interactive session causes the failure. I'm working on generalizing the process to further the evaluation. Will post results once completed.
Comment 17 Timothy Farmer 2014-07-10 09:45:43 EDT
It appears to be an issue with ksh being utilized by 3rd party applications in a non TTY session.

The above script was run via a remote agent with KSH version ksh-20100621-19.el6_4.3.x86_64 and completed successfully. A localized test case was also run via  setsid sh -c 'tty; ps -jp "$$"; .//test.sh' < /dev/null > ./test_sh.log 2>&1 which also completed successfully. This issue has only recently resurfaced. I will continue to investigate to see if I can provide a further breakdown.
Comment 18 Michal Hlavinka 2014-09-10 06:31:21 EDT
(In reply to Timothy Farmer from comment #17)
> I will continue to investigate to see if I can
> provide a further breakdown.

Hi, any success with reproducer?
Comment 19 Jeffrey Ross 2014-09-16 01:37:36 EDT
I have the same problem with ksh receiving nothing from `hostname -s` when run in the background.  But I haven't found a simple method of reproducing it.  On my system (6.5 with ksh-20120801-10.el8.i686) I have set up upstart to use a script entry to start a script that starts X & mwm (Motif Window Manager) and mwm is configured to call another script to open a window and remote-shell onto a machine.  That latter script works fine from the command line, but not from the mwm menu.  Using strace I can see that "hostname" is called, returns the host name as a string, but sends it to /dev/null instead of stdout.  So the script line "DISPLAY=`hostname -s`:0" gets simply ":0".
Changing the scipt from "#!/bin/ksh" to "#!/bin/sh" solves the problem and is an acceptable work-around for me.
Comment 20 Kamil Dudka 2016-10-20 08:12:48 EDT
The bug described in comment #0 appears to be fixed.  Please open a separate bug report with clear steps to reproduce if you need any further improvements.

Note You need to log in before you can comment on or make changes to this bug.