[2019-08-12 17:45] Jesse Smith <jsm...@resonatingmedia.com>
> >> I tried it and the "head", "cat" and "tail" commands mangle the lines
> >> of the log file when escape sequences are not escaped. Output from
> >> "less" is clean though and looks correct.
> > Interesting. Can you please send text that shows this behaviour?

> Certainly. Attached is a file with the last 20 lines of the
> /var/boot/log file on a test machine. When I view the log with "less"
> the output looks normal. When I run the file through "head" "tail" or
> "cat" the "[ ok" part of the message line appears at the beginning of
> the text. This happens in both the text console and in a virtual
> terminal window.

Ah, everything is clear now. Log file contains following escape
sequence:

  <ESC> [ 1 G

It moves cursor to first column of terminal, so text after displaces
text (timestamp) at beginning of line.

On other hand, `less -R' do not interpret cursor movement sequences
(quote from less(1)):

        For the purpose of keeping track of screen appearance, ANSI
        color escape sequences are assumed to not move the cursor.

If you use `less -r', output will be same as with `head', but I expect
`less' get confused on scrolling.

Cursor movement control sequences are okay for presentation, but are
very fragile to be stored and manipulated in any way.

I already filed bug to src:lsb to avoid control sequences more complex
than coloring.
-- 
Note, that I send and fetch email in batch, once in a few days.
Please, mention in body of your reply when you add or remove recepients.

Reply via email to