将 Org Babel 的 src 中的错误重定向到结果

问题描述 投票:0回答:1

Org 的 babel 可以将 stdtout 导出到结果

#+BEGIN_SRC shell
echo "testing "
#+END_SRC

#+RESULTS:
: testing

并向新缓冲区或迷你缓冲区报告错误

#+BEGIN_SRC shell
e 
#+END_SRC

#+RESULTS:

错误出现在新的缓冲区中

/bin/bash: line 1: e: command not found

如何将错误重定向到

#+RESULTS

shell emacs org-mode org-babel
1个回答
0
投票

您可以将 stderr 重定向到 stdout。

#+BEGIN_SRC sh :prologue exec 2>&1
  e
#+END_SRC 

#+RESULTS:
: sh: 2: e: not found

您可能还想添加

:epilogue true
来抑制可能出现的
[ Babel evaluation exited with code 127 ]

© www.soinside.com 2019 - 2024. All rights reserved.