From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6184 invoked by alias); 7 Apr 2014 15:44:25 -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: 18705 Received: (qmail 13904 invoked from network); 7 Apr 2014 15:44:19 -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 From: Bart Schaefer Message-id: <140407084404.ZM8781@torch.brasslantern.com> Date: Mon, 07 Apr 2014 08:44:04 -0700 In-reply-to: Comments: In reply to "Yuri D'Elia" "Reading output into variables" (Apr 7, 4:20pm) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Reading output into variables MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Apr 7, 4:20pm, Yuri D'Elia wrote: } } Maybe a stupid question, but is there a way to read the output of a } program and split into variables _conveniently_ using the IFS? Like Peter, I'm a little confused about what you're asking. A basic constraint of the way that I/O works in unix-like systems is that you have to use either the filesystem or a separate process to "read the output" of anything without danger of deadlock. So when you ask for ... } program | read a b } } minus the subshell. ... it would seem to imply that "program" is a shell construct so it doesn't need an extra process in the first place, which leaves a temp file as the only answer to your question ... but that probably isn't as "convenient" as you want. But then you give this example ... } program | { read a b; hooray } ... which leaves me uncertain as to what "subshell" you were talking about in the first example. Perhaps you mean something like set -- $(program) which still uses a subshell but splits on IFS into $1 $2 etc. Which means you have to be done using those as program / function arguments. } Bonus points if that's something that would also work in bash. The above "set" solution works in bash. In zsh you could also do set -A array -- $(program) to avoid clobbering $1 et al.