Bug 1022589 - ksh nested command substitution failure
ksh nested command substitution failure
Status: CLOSED DUPLICATE of bug 1011642
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: ksh (Show other bugs)
6.4
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Michal Hlavinka
BaseOS QE - Apps
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-23 11:16 EDT by Richard Brittain
Modified: 2013-10-24 09:21 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-10-23 12:04:32 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 Richard Brittain 2013-10-23 11:16:33 EDT
Description of problem:
Nested command substitutions fail with apparent race condition

Version-Release number of selected component (if applicable):
Name        : ksh                          Relocations: (not relocatable)
Version     : 20100621                          Vendor: Red Hat, Inc.
Release     : 19.el6_4.4                    Build Date: Thu 16 May 2013 09:25:18 AM EDT

How reproducible:
If inner command completes quickly, the combination fails

Steps to Reproduce:
1. Create a file with your own hostname in it, e.g. /etc/hosts
2. line=$(cat /etc/hosts | grep $(hostname))
3.

Actual results:
line=$(cat /etc/hosts | grep $(hostname))
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.

Expected results:
matching line from /etc/hosts

Additional info:
If inner command is $(hostname;sleep 1), the commnd works as expected.  This seems to work as expected in bash.
Comment 2 Michal Hlavinka 2013-10-23 12:04:32 EDT

*** This bug has been marked as a duplicate of bug 1011642 ***
Comment 3 Richard Brittain 2013-10-23 12:25:03 EDT
I don't this is the same as the other bug, though they may be related.  I think it is a race condition, nothing to do with ttys.

Another example, not using hostname

Failure:
$ echo $(date | sed -es"/$(date +%Y)/foo/" )
sed: -e expression #1, char 0: no previous regular expression

Success, with enforced delay:
$ echo $(date | sed -es"/$(date +%Y; sleep 1)/foo/" )
Wed Oct 23 12:10:05 EDT foo
Comment 4 Michal Hlavinka 2013-10-24 09:21:14 EDT
Still the same bug.
Original bug has reproducer
echo ok | echo $(hostname) -> no output
echo ok | echo $(hostname; sleep 1) -> correct output

It's about handling list of commands in subshell, no race condition

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