misc/163871: 'script' save endline as ^M
brde at optusnet.com.au
Sat Jan 7 06:00:24 UTC 2012
On Fri, 6 Jan 2012, Eugen Konkov wrote:
> there must not be ^M endline style
> Script done, output file is typescript
> when look into 'typesript' file in 'mc' you can see ^M as endline
> Edit src/sys/dev/et/if_etreg.h^M
> Add delta 18.104.22.168 2012.01.06.18.15.27 yongari^M
This is a mostly a feature. script(1) just echos whatever data goes
through the pty. Normally the pty is in "opost onlcr" mode, so \n is
translated to \r\n. script(1) can't possibly undo this, because it
is impossible in general for it to distinguish between \r's that are
the result of the translation and \r's that are needed (e.g., the one
printf 'The following \\r is not needed'
printf 'The preceding \\r __is__ needed!\n'
If you don't want this, then turn off onlcr or opost. You won't like
the result of this in interactive shells unless the terminal translates
nl to crnl and you don't turn this off too.
However, watch(8) doesn't have this problem, since it sees and reports
the data written to the terminal before opost processing.
watch(8) probably works better for input too. Someone recently tried to
fix EOF handling in script(1) and had problems using VEOF since this gives
input processing unless the default echo mode is turned off. Perhaps
watch(8) can handle this better too. But watch doesn't understand EOF at
all, and is hard to terminate (the old version that I'm testing with
is terminated by ^G which generates a SIGINT, but it dumps core instead
of catching this signal as intended, and all versions have an unsafe
SIGINT handler which asks for core dumps).
More information about the freebsd-bugs