Bug 1022589 - ksh nested command substitution failure
Summary: ksh nested command substitution failure
Keywords:
Status: CLOSED DUPLICATE of bug 1011642
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: ksh
Version: 6.4
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Michal Hlavinka
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-10-23 15:16 UTC by Richard Brittain
Modified: 2013-10-24 13:21 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-10-23 16:04:32 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Richard Brittain 2013-10-23 15:16:33 UTC
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 16:04:32 UTC

*** This bug has been marked as a duplicate of bug 1011642 ***

Comment 3 Richard Brittain 2013-10-23 16:25:03 UTC
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 13:21:14 UTC
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.