From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22231 invoked by alias); 14 Nov 2015 08:01:11 -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: 20954 Received: (qmail 27812 invoked from network); 14 Nov 2015 08:01:08 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 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:content-type; bh=LSi9pzVpQTSxcWJ6bksKHZTwi0MHzUBcm55xfsUkSzA=; b=kySVRqxdq2lv78R5voR+cpHD8Cx6AQJYKJoo/zgHnETqNQhDfUt2DJk+SCFO631v3F fISjYKxzOF7qgOr8u7qngLbc6OroD42hUjsZ+2g1xxfxL8rQIgW1YPv61rh9WLsmMhcf n4dd4cXPGsKrW90JQlqSF1PO7PCcInI6NeNKrawTXlXRjysFmOVRFWsQJEYMEK2WuNNd VeivqiYTN5WzildrmoLf79YqAfQzdsWUm3Yo2GkeRaweZE1MaGX3H5AyT2Jjr9M1Wcuy 5m3iVGo6jsMwKuadanK3LHmUSyxPC3nSYuw0xRS01VeUQUc/rmlFhU1Ah54Sn7Q6uz+K L8Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=LSi9pzVpQTSxcWJ6bksKHZTwi0MHzUBcm55xfsUkSzA=; b=d1vE/ghwvM8dX38o31Ohx95hT9E/s55BbOG3WTWbO3ZE7yloIy/kx7i0X8bR6VMWZm 8RSF3+6WHPOHbiiEv4YQXoI0o7dWdFT0IgghOotLuMrCC7tu7rTtiXP0WtQLgpOJwjV0 1EV2vaU0+rFr1UvlAc3APV9J941DUp0N8mqlbmy+C9wZ8qRsaZodsU1oU4Gdd/bKNoQ/ XdoaspTOmtwgQcZ3KPG2NDupj7lgABlu/uv06NIz0w3bsQmxnyc/tdaVBJVrEihoaCSj HfR+vSOStW1Q/XcR/Jl5wcqtuem4eKbdmEpEtkYqU0q9gnfgsp2eJfN87F6SeE85Q697 mmCQ== X-Gm-Message-State: ALoCoQledXo1jUm4NnuczaXpVxkwvLnd7IKMitMrzC+KYJZnCIlae3semVtXE58EIoPMu7j53AEc X-Received: by 10.202.195.132 with SMTP id t126mr14145664oif.117.1447488064245; Sat, 14 Nov 2015 00:01:04 -0800 (PST) From: Bart Schaefer Message-Id: <151114000101.ZM611@torch.brasslantern.com> Date: Sat, 14 Nov 2015 00:01:01 -0800 In-Reply-To: Comments: In reply to Mikael Magnusson "Re: capturing stderr to variable." (Nov 14, 7:56am) References: <5646B5F8.3090702@eastlink.ca> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh Users Subject: Re: capturing stderr to variable. MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Nov 14, 7:56am, Mikael Magnusson wrote: } } On Sat, Nov 14, 2015 at 5:18 AM, Ray Andrews wrote: } > } > wondering, since redirection and piping are (I believe) at about the } > same level of parsing, one might suppose that " ... 2| " would be } > legal. That is to say that we could sent stderr to a command as well } > as to a file. } } foo 2> >(bar) That doesn't really help very much, though, because >(bar) runs in a separate process so the original shell can't do anything interesting with the captured output. The shell language doesn't define a digit preceding a "|" symbol as a redirection because "|" separates commands whereas ">" modifies the single current command. The difference makes more sense if you are aware that redirections can appear anywhere: % >file echo this goes to file % echo this >>file also goes to file Whereas "|" ends the command and begins the next. So, pipes work only on stdout, and to redirect stderr to a pipe you must first use 2>&1 to copy stderr to stdout ... which means even if you think it's unclear, you must first separately redirect stdout in order to pipe only stderr. E.g. { highlight ... >/dev/tty } 2>&1 | read highlight_err # now $highlight_err has the first line of stderr # (this does not work in most shells other than zsh) Note that without the braces, 2>&1 combines stdout and stderr so both go to /dev/tty and "read" either has no input or reads from the terminal (depending on whether the "multios" option is set). -- Barton E. Schaefer