0

I started to use emacs and orgmode for few weeks. I try to automate the documentation of a tool present on my bash environment and I want to print the help output of inside an org file. In the capture I join I execute 2 codes :

Legibility problem

I run this code :

#+begin_src bash :results: output replace 
  man ls
#+end_src

You can see the output format is not clear, is there a way to change it ? enter image description here

Buffer output problem

Here the context is that the tool is installed in a conda environment. So I run two lines of code: the first to activate the conda env and the second to get the help output of a tool named fastp.

#+begin_src bash :results: output replace
  source /home/dubos/anaconda3/bin/activate NGSTools
  fastp -h
#+end_src

As you can see on the following screenshot, the output appears in a separate buffer and not in the file. Do you have an idea why? enter image description here

4
  • 2
    See "redirecting stderr" for the 2nd issue. Stdout and stderr go to different places. emacs.stackexchange.com/questions/75778/… Commented May 17 at 13:36
  • @mankoff is correct in blaming the problem on the fact that fastp --help sends the output to stderr, whereas it should send it to stdout (in which case the only problem would be the extraneous :). That is a bug in fastp and an issue has been around for six(!) years without resolution. I've added a comment supporting the fix as well, but if you are using fastp, please complain to the author: he needs to fix it. Commented May 18 at 3:34
  • BTW, do NOT use fastp -h: that is taken as --html and complains about a missing value. Use fastp --help. Commented May 18 at 3:35
  • Thank's both for the bug's explaination. If I understand well I should run something like : fastp --help >&2? Commented May 19 at 7:50

1 Answer 1

0

The first thing you have to do is get the syntax right:

#+begin_src bash :results output replace 
  man ls
#+end_src

Note that there is no : after :results. For all the details and options, see Using Header Arguments in the Org mode manual.

That fixes the first code block.

The second has the same syntax problem. Fix that first and see what you get: I suspect that that will be enough to fix the second problem as well.

If you still have a problem however, open a new question. It is a different problem from the :results: syntax error. Here are some suggestions for what to include in your new question (if you need to ask it):

Note that the output buffer is called *Org-Babel Error Output* which suggests that your shell commands resulted in some error. It is not clear what that error is: we don't have your conda environment setup file and we don't have the fastp command to test with. You are going to have to debug it, or post more information about it. In particular, the complete buffer should be included in your question.

And note that screenshots are to be avoided, unless absolutely necessary. All of this is just text and you can include it verbatim in your question by enclosing it in triple backticks (see my edit to your question where I did that to your code blocks, instead of using the four-space indentation that you used, to see that in action). Better for us and easier and faster for you.


EDIT: as @mankoff mentions in his comment, the second problem is a combination of the above syntax error, a wrong invocation of fastp[1], and an unfortunate bug in fastp that sends the usage message to stderr instead of stdout. The bug has been reported (see this issue) but unfortunately it has languished unfixed for six (!) years. I added a comment in support of the fix, but I'm not sure if it will be heeded.


Footnote:

[1] fastp -h is short for fastp --html which requires a value, so the invocation causes an error: option needs value: --html. Use fastp --help to get the usage message, but read on for an additional problem.

1
  • Removing : work to solve the legibility problem. For the buffer output problem I will post and other question if I don't find a solution. Commented May 17 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.