Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Control+T in Terminal shows time snapshot' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Control+T in Terminal shows time snapshot
Authored by: fido on Jan 28, '12 07:46:13AM
Any Unix program can see the CR's and LF's separately if the programmer chooses. They just have to turn off icrnl or put the tty into raw mode. To say that there is no difference between the two is a little misleading.

Example:

#!/bin/sh
stty -icrnl
echo "Type something, hit control M or enter/return a few times, then hit control J"
read ans
echo "You typed:"
echo $ans | od -a
stty icrnl
Also, control V is the usual setting for the tty's "literal next" (lnext) setting and is not limited to command line editors. Try running a simple command like sleep 30, then hit ^V^M and ^V^J to see that there is a difference between the two.

In Terminal the key labelled "return" will produce the same results as hitting ^M because they're both ways to generate a carriage return (CR). If icrnl is on (see stty -e) then these will be mapped to newlines.

[ Reply to This | # ]