From mboxrd@z Thu Jan 1 00:00:00 1970 From: Karl Voit Subject: Re: Redirecting stderr to stdout with babel/shell Date: Sun, 11 Jan 2015 16:02:46 +0100 Message-ID: <2015-01-11T15-57-47@devnull.Karl-Voit.at> References: <2015-01-01T17-23-41@devnull.Karl-Voit.at> <87lhl9wnj4.fsf@Rainer.invalid> Reply-To: Karl Voit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAK2j-0007KI-In for emacs-orgmode@gnu.org; Sun, 11 Jan 2015 10:03:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YAK2g-0000hj-Ad for emacs-orgmode@gnu.org; Sun, 11 Jan 2015 10:03:05 -0500 Received: from plane.gmane.org ([80.91.229.3]:48232) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAK2g-0000gp-4d for emacs-orgmode@gnu.org; Sun, 11 Jan 2015 10:03:02 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YAK2f-0006kt-5S for emacs-orgmode@gnu.org; Sun, 11 Jan 2015 16:03:01 +0100 Received: from friends.grml.info ([136.243.234.19]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 11 Jan 2015 16:03:01 +0100 Received: from news1142 by friends.grml.info with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 11 Jan 2015 16:03:01 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org * Achim Gratz wrote: > Karl Voit writes: >> echo "testing stderr with manual redirect" 2>&1 >&2 > > The last redirection ">&2" is nonsense, it only works because STDERR is > already reopened on STDOUT and redirection to the same file descriptor > is ignored. Absolutely right. Must have been a non-deleted artefact after I tested something different in that line. > And to solve your original problem: > > #+BEGIN_SRC sh :results output > exec 2>&1 > echo "testing stdout" >&1 > echo "testing stderr" >&2 > date -g > : > #+END_SRC Together with the '{ ... } 2>&1' trick, this is a valid workaround. What I wanted to achieve is a re-direct of any (sh) babel script without this exec-command I do have to add. However, I could imagine an additional babel-parameter like ":stderr redirect" (or something more meaningful) because in most cases I have to add the ":results output" line as well. -- mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode: > get Memacs from https://github.com/novoid/Memacs < https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github