From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4158 invoked by alias); 21 Aug 2014 19:58:46 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 33039 Received: (qmail 15589 invoked from network); 21 Aug 2014 19:58:33 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=no version=3.3.2 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-workers@zsh.org From: Stephane Chazelas Subject: $? and suspended jobs Date: Thu, 21 Aug 2014 20:37:00 +0100 Message-ID: <20140821193700.GA8273@chaz.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 2e407643.skybroadband.com Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) ~$ sleep 4; echo $?, $pipestatus ^Z zsh: suspended sleep 4 20, 0 Why not 128+20 = 148? I'd expect $pipestatus to contain the same value as $? ~$ {sleep 5; echo $?} ^Zzsh: suspended { sleep 5; echo $?; } (20)1~$ fg [1] + continued { sleep 5; echo $?; } 20 (that "(20)" is $? in my prompt). Here `echo $?` is run after sleep finishing and returning a 0 exit status. Still $? is always based on SIGTSTP. ~$ {(sleep 5; echo "$?"; exit 12); echo $?, $pipestatus} ^Zzsh: suspended { ( sleep 5; echo "$?"; exit 12; ); echo $?, $pipestatus; } (20)1~$ fg [1] + continued { ( sleep 5; echo "$?"; exit 12; ); echo $?, $pipestatus; } 0 20, 0 $? is always 20 and $pipestatus always 0 regardless of the exit status of the command that is resumed. You might say there's value in that (one may want to consider a command that was suspended as having failed), but the behaviour is quite surprising. Spawned from a question at: http://unix.stackexchange.com/questions/151376/how-do-i-gracefully-suspend-and-resume-cmd1-cmd2-cmd3-chain -- Stephane