Hide Forgot
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.
*** This bug has been marked as a duplicate of bug 1011642 ***
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
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