When I run a shell command in Org I sometimes get back weird control characters:
#+begin_src sh :results output :session test
guix pull
#+end_src
#+RESULTS:
:
: Updating channel 'guix' from Git repository at 'https://git.savannah.gnu.org/git/guix.git'...
: Building from this channel:
: guix https://git.savannah.gnu.org/git/guix.git 258a27e
: Computing Guix derivation for 'x86_64-linux'... ^H-^H^H|^H/^H-^H^H|^H/^H-^H^H|^H/^H-^H^H|^H/^H-^H^H|^H/^H-^H^H|^H/^H-^H^H|^H/^H-^H^H|^H/^H-^H^H|^H/^H-^H^H|^H/^H-^H^H|^H/^H-^H^H|^H/^H-^H^H|^H/^H-^H
: nothing to be done
It's not just ^H
, but many others. I can replace them if I have them present. However, I can't store them in a regex within a clean-up function because it's not clear how to encode the file it's saved in.
Answers to similar questions have suggested to check locale. I would think this should be okay:
#+begin_src sh :results output :session test
export | grep LANG
#+end_src
#+RESULTS:
: export GDM_LANG="en_US.utf8"
: export LANG="en_US.utf8"
Others have suggested changing PS1
in .bashrc
. These made no difference. It seems the shell used by Org is already stripped down:
#+begin_src sh :results output :session test
echo $PS1
#+end_src
#+RESULTS:
:
: \s-\v$
Still more have suggested bracketed paste mode may be a factor. It may be, but definitely not for the guix pull
above. As far as I understand, bracketed paste mode is only for ESC [ 2 0 0 ~ ,
and ESC [ 2 0 1 ~ .
. I have not seen these or, at the very least can't reproduce them.
I'm at a loss for how to clean up these control characters or, better yet, not produce them in the first place. Any advice?
guix pull > guix.out 2>&1
and check the output file withM-x find-file-literally
. If that includes the weird characters, then you have to filter the output ofguix pull
. Maybe there is an option to turn the weird characters off. The^H-
suggests that it's trying to produce an overstrike effect. – NickD Oct 17 '21 at 12:59