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
?
您可以将 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 ]
。