Pulimon Pulimon - 2 years ago 108
Bash Question

Issues with newline character while using ansi-term in emacs

I am trying to use ansi-term in emacs (configured to tcsh shell). I see some issues with newline characters being displayed. If I try the following from the terminal (ansi-term), I get the correct output:

myterm > echo "Line1"; echo "Line2"; echo "Line3";
myterm >

But if I try putting the same lines in a shell script and try to execute the script from ansi-term, I get a wrong output

Script: (test)

#!/usr/bin/env tcsh
echo "Line1"; echo "Line2"; echo "Line3";

Running the script (test):

myterm > ./test
myterm >

Note: /usr/bin/env tcsh does point to the correct shell (its the same shell that I used while invoking ansi-term). Also executing the script from gnome-terminal also displays the correct output.
I have also tried setting the following variables but it did not solve my issues:

(set-terminal-coding-system 'utf-8-unix)
(setq default-process-coding-system '((utf-8-unix . utf-8-unix)))

Answer Source

You need to stty onlcr in your script.

I will leave the forensics of exactly where this is being unset in the tcsh environment as a exercise for the questioner ;)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download