From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13016 invoked by alias); 25 Apr 2013 18:27:23 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17779 Received: (qmail 15684 invoked from network); 25 Apr 2013 18:27:20 -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.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <130425112711.ZM17317@torch.brasslantern.com> Date: Thu, 25 Apr 2013 11:27:11 -0700 In-reply-to: Comments: In reply to "Yuri D'Elia" "Re: precmd: write error: interrupted" (Apr 25, 7:44pm) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: precmd: write error: interrupted MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Apr 25, 7:44pm, Yuri D'Elia wrote: } } On 04/25/2013 06:47 PM, Yuri D'Elia wrote: } > 2) Why "precmd() { { print "HELLO" } >&- 2>&-; } doesn't suppress the } > error in this case? } } Closest analogue I could find is: } } % { { print >&2 } 2>&- } 2>/dev/null } zsh: write error Of course what's happening here is in outside-in order. Starting with the stuff you can mostly see: 1. stderr is redirected to /dev/null (old stderr is saved) 2. stderr is closed (at this point the outer redirection is gone) 3. print generates an error Now the stuff you can't see happens: 4. zsh gets another error writing to the closed stderr 5. zsh warns about that to the saved stderr from step 1 You avoid the whole mess if you never close stderr, or if you close it before step 1 (e.g. by "exec 2>&-"), though the latter is impractical in the case we're discussing.