From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4908 invoked by alias); 10 Mar 2017 17:22:30 -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: 22553 Received: (qmail 24273 invoked from network); 10 Mar 2017 17:22:30 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr0-f195.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.128.195):SA:0(0.5/5.0):. Processed in 1.006891 secs); 10 Mar 2017 17:22:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,RCVD_IN_SORBS_SPAM,SPF_PASS, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: stephane.chazelas@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.128.195 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=T87y9uRHT3roK10jCp++QuMfUa8Clbncn+Kpq3T8534=; b=B8PxgKtmabjM303Mu9JxXaZHGYE+sKt099ppxN+y6FAfl6pL2iT1+JwBFzRaUnTOjI 6NovQ+rHLgJbF7OJ07TofgYIvQWvF35wppv3vfEuo/qLrnD4f4IDVt1bePIBWRvHX3Dc dCtUybipRCQZdhkyd3+pBkYmWcA1CAspyd5Ifn/EiKYIUOiG27Q64Hs9QZfWfjY7VWzA i953c+OLR1DhqsC7CwuPsKBmlzl7FaFhytepwrKysOBWQnACODv8QwtOLSfzh7KoASYF f7XscCP9lxxucs8zeqWC3xl2E6+Fp5RIJV3pRyp/1VgjjIlwUWp8gUs4xyHSKpmNiPXf YFug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=T87y9uRHT3roK10jCp++QuMfUa8Clbncn+Kpq3T8534=; b=l7rOO9KApwLSknVZuqT4EiHH+t2K73lWWYRJEEBEb+x+gI2D5Bd4BBzFQD7K+BmIy+ FBSbcHd8/uj9EhQLREcg+hQemqd/aKxXjsr5yjQ2NMu3PXVeBe+2XX+ZXqVVNz2DLt+F SLsp6r1GqGkciGhUVSwcOZYbsJJ/A7TGDxK3L8DdGK1zuEqbCb/t5xvlFJMGpVZ2riYZ 9us33jJ+9giSVQpFbn/viswFOBofNVtEKZmUqZhaMNKHUUdGlgWoyQjTfy8W27+FMYNk f5jEqk5iyilb3Ul78GTkQY+us7fUAqhXfH1F9RhiOLWOhXtddqwwra+vqpkOgZErOHbk w0PQ== X-Gm-Message-State: AMke39lsoHFskhdzj+HWfi8+Q2pNZq2tXVUhZTmb43MtvgfHVSYDcry3ZsW4OXMcb9N+5Q== X-Received: by 10.223.153.225 with SMTP id y88mr16217576wrb.81.1489166543029; Fri, 10 Mar 2017 09:22:23 -0800 (PST) Date: Fri, 10 Mar 2017 17:22:19 +0000 From: Stephane Chazelas To: Bart Schaefer Cc: Nathan Dorfman , zsh-users@zsh.org Subject: Re: Redirect a specific file descriptor to a pipe? Message-ID: <20170310172219.GA4206@chaz.gmail.com> Mail-Followup-To: Bart Schaefer , Nathan Dorfman , zsh-users@zsh.org References: <170309180417.ZM14034__34042.4779606566$1489111700$gmane$org@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <170309180417.ZM14034__34042.4779606566$1489111700$gmane$org@torch.brasslantern.com> User-Agent: Mutt/1.5.24 (2015-08-30) 2017-03-09 18:04:17 -0800, Bart Schaefer: > On Mar 9, 5:21pm, Nathan Dorfman wrote: > } > } strace -o /dev/fd/3 ./a.out > out.log 2> err.log 3>XXX > } > } Instead of file XXX, I'd like to send fd 3 to |less. Is it possible? > > You just need this: > > strace -o /dev/fd/3 ./a.out > out.log 2> err.log 3>&1 | less [...] No quite. There are two issues here, one zsh specific: cmd > file | cmd2 In zsh (with multios on by default) is special and redirects stdout both to file and cmd2 (and the 3>&1 would also redirect fd 3 to both). In Bourne-like syntax, you'd also need to change the order: strace -o /dev/fd/3 ./a.out 3>&1 > out.log 2> err.log | less That is, redirect the fd 3 to the same thing as fd 1 at the time that fd 1 was the pipe, *and then* redirect fd 1 to out.log. In zsh, to avoid the multios effect, you can do: {strace -o /dev/fd/3 ./a.out 3>&1 > out.log 2> err.log} | less or disable multios (set +o multios). -- Stephane