Loading ...
Sorry, an error occurred while loading the content.
 

Re: Line endings of messages to stderr in batch mode

Expand Messages
  • Bram Moolenaar
    ... In a terminal the CR characters are required. A NL (aka line feed) only moves the cursor to the next line, it doesn t go back to the first column. In the
    Message 1 of 3 , Apr 28 6:07 AM
      David B├╝rgin wrote:

      > When run in batch mode, Vim prints verbose :echo messages to stderr (see
      > ":h -s-ex").
      >
      > Unfortunately, by the look of it end-of-line characters aren't handled
      > correctly. On my unix machine I get CRLF line endings, and no line
      > endings on the last line.
      >
      > To reproduce, create a script "crlf.vim" with the following contents.
      >
      > function Echo()
      > echo "a"
      > echo "b"
      > echo "c"
      > endfunction
      > verbose call Echo()
      > quit
      >
      > Execute it in batch mode, redirecting stderr to a temporary file.
      >
      > vim -es <crlf.vim 2>tempfile
      >
      > These are the contents of the tempfile:
      >
      > 0000000: 610d 0a62 0d0a 63 a..b..c
      >
      > Whereas the output I would expect in a unix environment looks like this:
      >
      > 0000000: 610a 620a 630a a.b.c.

      In a terminal the CR characters are required. A NL (aka line feed) only
      moves the cursor to the next line, it doesn't go back to the first
      column.

      In the tty handling the CR is often automatically inserted, depending on
      the mode. Vim assumes raw mode, thus has to write the CR characters.

      --
      "Marriage is a wonderful institution...
      but who wants to live in an institution?"
      - Groucho Marx

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ an exciting new programming language -- http://www.Zimbu.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • glts
      ... Ok, thanks. I didn t understand the explanation, to be honest, as I know nothing about terminals/ttys. To my naive understanding the behaviour is still
      Message 2 of 3 , Apr 28 10:11 AM
        On Sun, Apr 28, 2013 at 3:07 PM, Bram Moolenaar <Bram@...> wrote:
        > In a terminal the CR characters are required. A NL (aka line feed) only
        > moves the cursor to the next line, it doesn't go back to the first
        > column.
        >
        > In the tty handling the CR is often automatically inserted, depending on
        > the mode. Vim assumes raw mode, thus has to write the CR characters.

        Ok, thanks. I didn't understand the explanation, to be honest, as I know
        nothing about terminals/ttys.

        To my naive understanding the behaviour is still different from that of
        other utilities. For example when I use an invalid command with sed, its
        stderr output is still well-formed in unix terms, with just an LF at the
        end of every line.

        cat textfile | sed -e 'crash' 2>tempfile

        It isn't clear to me why Vim in batch mode doesn't produce similarly
        well-formed lines. I'll try to read up on this.

        --
        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      Your message has been successfully submitted and would be delivered to recipients shortly.