From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Is it possible to capture stdout and stderr to separate variables in Zsh?
Date: Fri, 30 Mar 2012 07:49:00 -0700 [thread overview]
Message-ID: <120330074900.ZM14469@torch.brasslantern.com> (raw)
In-Reply-To: <CADdV=MsoGfZTN0A8ANG7EZdHa_OQk-dpWSdubNRADwgfRuB6qQ@mail.gmail.com>
On Mar 30, 9:15am, Nikolai Weibull wrote:
} Subject: Re: Is it possible to capture stdout and stderr to separate varia
}
} On Thu, Mar 8, 2012 at 15:53, Bart Schaefer <schaefer@brasslantern.com> wrote:
} > On Mar 7, 10:26am, Nikolai Weibull wrote:
} > }
} > } outs=("${(@0):-"$({ out=$(x) } 2>&1; print $'\0'$out$'\0'$status)"}")
} >
} > That's nice. You can solve the problem that Philippe mentioned with
} > loss of trailing newlines, by embedding one NUL in $out like so:
} >
} > outs=("${(@0):-"$({ out="$(x; print -n $'\0')" } 2>&1;
} > print $'\0'$out$status)"}")
}
} That will, however, override the value of $status.
Indeed, good catch. You need to pull $status inside the $(...) too
(in which case the trailing newline doesn't matter any more):
outs=("${(@0):-"$({ out="$(x; print $'\0'$status)" } 2>&1;
print $'\0'$out)"}")
next prev parent reply other threads:[~2012-03-30 14:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-06 8:09 Nikolai Weibull
2012-03-06 17:16 ` Philippe Troin
2012-03-07 7:01 ` Bart Schaefer
2012-03-07 9:26 ` Nikolai Weibull
2012-03-08 14:53 ` Bart Schaefer
2012-03-30 7:15 ` Nikolai Weibull
2012-03-30 14:49 ` Bart Schaefer [this message]
2012-09-10 6:16 ` Han Pingtian
2012-03-07 19:37 ` Philippe Troin
2012-03-08 4:56 ` Bart Schaefer
2012-09-01 11:59 ` Han Pingtian
2012-09-09 19:18 ` Bart Schaefer
2012-08-31 0:40 ` Paul Maisano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=120330074900.ZM14469@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).