From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 749 invoked by alias); 11 Mar 2017 02:24:04 -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: 22558 Received: (qmail 2709 invoked from network); 11 Mar 2017 02:24:04 -0000 X-Qmail-Scanner-Diagnostics: from mail-vk0-f41.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.213.41):SA:0(-0.0/5.0):. Processed in 1.001957 secs); 11 Mar 2017 02:24:04 -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.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.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.213.41 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=3rQGwYMXW7WNBpsuOKFxB9q7IMQdbt4/+2VJeUaorfA=; b=ABj9d3bpUG4tvyXMynOJGSUY8zezCSBn2AsWHB26BgfROMlGIJAhooOXZ6dEh3ijbn inWW8Ep8wS989Oblh5jCknh4YiT5/1rrVyc93lORVfHNt8Io9FcdQVLiFdUezF8nWTbg 829FAfZmQUSTIPPfCJ4kOr/VbX366H6UYV7x+ovKx7o3KjC5E+rdT+71/aGzF18vNTcH GNQYiEKZQszmCARukFKbCHpo/93Kmv4JIJyCru93dD3YT3Bkyh2YxUcT1zPK6ukPV6KR hPBAzKwdy+YIRHJf4+OWCqkFJc7La94o+7F+OP/SWKR0KzjEFV9sdr6zfpN3Wr7UFFlS 2EpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=3rQGwYMXW7WNBpsuOKFxB9q7IMQdbt4/+2VJeUaorfA=; b=pbCuGMgoK9/kNYbAXW8lplmpWizVzIyNOJobx4Wili33PF4VH4TKYxdqX76SZbaU09 C/Ze1nmBhyAx1fXVfzoT9E4R47K6k/yRNBDHN0TuZ+kUUfZs5j8K3dRRDeEd33VWe89W TrkNL3xtRyV2EhgHzk6CIXFDMxC0o0B7GEYNH/+9AyaNtdl5L/EHpyXZtxIrz4oDehqi juohWOCZ4Jmvt9BKgTMDbYY/MWBt7IiUxdypohk/9TTr99nKo8d3WYMSNd/xQ6v6oJu1 ZqL6eLB9q2Ao6rFXMOD5x6IK97RpTZlWjoyFqb876hvYrIzpMtoewWCZm1M9vkUDk+1e QNAQ== X-Gm-Message-State: AMke39kW06N+SboJz9skZt+EVyFpsfuqxZhNq4xa7QezEZd2yzt3SBKBRLCka0kLnxk3Mw== X-Received: by 10.31.16.69 with SMTP id g66mr9027047vki.66.1489199036940; Fri, 10 Mar 2017 18:23:56 -0800 (PST) From: Bart Schaefer Message-Id: <170310182430.ZM17517@torch.brasslantern.com> Date: Fri, 10 Mar 2017 18:24:30 -0800 In-Reply-To: Comments: In reply to Nathan Dorfman "Re: Redirect a specific file descriptor to a pipe?" (Mar 10, 4:32pm) References: <170309180417.ZM14034__34042.4779606566$1489111700$gmane$org@torch.brasslantern.com> <20170310172219.GA4206@chaz.gmail.com> <170310105112.ZM843@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Redirect a specific file descriptor to a pipe? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Mar 10, 4:32pm, Nathan Dorfman wrote: } } I still think it might be useful to be able to pipe any fd, not just } stdout, but I don't know if I can contrive a great example. It depends on what your intentions are. The definition of a pipeline in shell syntax is that the standard output of the left side connects to the standard input of the right side. So if you want to use a pipe, you have to make the right thing *be* stdout, regardless of which other descriptor it might have started out to be. So when I talk about intentions: Where do you expect stdout of the left side to go if some other descriptor is feeding the pipe? } Perhaps we } can't redirect stdout because it's a curses program that needs direct } terminal access, but we want to do something like this: } } strace -o /dev/fd/3 mutt 3>XXX } } Where instead of XXX, we want to send fd 3 to |xz or |ssh? In that example you want "mutt" to remain the foreground process (it can't share the terminal with xz or ssh). So you have to run xz in the background. That is what process substitution is for: strace -o /dev/fd/3 mutt 3>>(xz) This puts xz in the background with its input connected to fd 3 and it's output still connected to the terminal, while mutt stays in the foreground with stdin + stdout unchanged. It's up to you (or to xz) to make sure the subshell doesn't attempt to spew something onto the terminal mutt is using. On Mar 11, 1:17am, Mikael Magnusson wrote: } } whatever_command 5> >(pipe command here) 7> >(some other pipe here) } } but now that i'm testing it, it seems to not complete when it should It's not hung, >(some other pipe here) is in the background so its output has probably been printed below the prompt. Try strace -o /dev/fd/7 =true 7> >(cat); wait which will wait for >(cat) to finish before printing another prompt [it is a relatively recent change to zsh that you can "wait" for process substitution background jobs].