| Summary: | zsh code block/pipe problem | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 5 | Reporter: | D Newport <dennis.newport> |
| Component: | zsh | Assignee: | James Antill <james.antill> |
| Status: | CLOSED NOTABUG | QA Contact: | BaseOS QE - Apps <qe-baseos-apps> |
| Severity: | medium | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 5.5 | CC: | prc |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2011-03-31 19:42:16 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
I believe this is intentional, in that only the _last_ command in a pipe is executed within the current shell and all the others are in subshells (with a couple of optimizations, for cases zsh knows you can't tell the difference).
% print $ZSH_SUBSHELL
0
% print $ZSH_SUBSHELL | cat
0
% {print $ZSH_SUBSHELL}
0
% {print $ZSH_SUBSHELL} | cat
1
% echo | cat | {print $ZSH_SUBSHELL}
0
% print_sub () { print $ZSH_SUBSHELL }
% print_sub
0
% print_sub | cat
1
% echo | cat | print_sub
0
|
Description of problem: The following two examples show the problem: 1) typeset -i RC=0 { ls xxx 2>/dev/null; RC=$? } echo $RC 2 2) typeset -i RC=0 { ls xxx 2>/dev/null; RC=$? } | tee /tmp/yyy echo $RC 0 In 1) above the value in the RC env var is correct. When a |tee is added then it appears that the code block is executed as a subshell and hence RC is not set. Version-Release number of selected component (if applicable): zsh-4.2.6-3.el5 zsh-debuginfo-4.2.6-2.hotfix How reproducible: See examples above. Steps to Reproduce: 1. 2. 3. Actual results: Expected results: Additional info: