grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug#586358: grub-pc: Please handle DOS line endings in "cat"


From: Vladimir 'φ-coder/phcoder' Serbinenko
Subject: Re: Bug#586358: grub-pc: Please handle DOS line endings in "cat"
Date: Fri, 25 Jun 2010 20:51:12 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100515 Icedove/3.0.4

>
> On Fri, Jun 18, 2010 at 11:34:08AM -0700, Josh Triplett wrote:
>   
>> The "cat" command, if given a file with DOS line endings, will show the
>> \r at the end of every line as a control character.  For convenience,
>> please consider adding support for this in "cat", ideally automatically.
>>     
> Makes sense to me.  grub-devel, how about this patch?
>
>   
Unconditionaly stripping \r is a bad idea because sometimes cat in grub
is used to determine why the system fails to boot. And if by a stupid
action fstab becomes DOS-formated 'cat /etc/fstab' will fail to show
this important point. But it's ok to add an option for cat'ing DOS
files. In this case we probably need to mark unix newlines somehow to
detect a reverse problem
> 2010-06-20  Colin Watson  <address@hidden>
>
>       * commands/cat.c (grub_cmd_cat): Print DOS "\r\n" line endings as
>       simple newlines.
>
> === modified file 'commands/cat.c'
> --- commands/cat.c    2010-03-01 19:24:34 +0000
> +++ commands/cat.c    2010-06-20 22:11:37 +0000
> @@ -54,6 +54,11 @@ grub_cmd_cat (grub_command_t cmd __attri
>  
>         if ((grub_isprint (c) || grub_isspace (c)) && c != '\r')
>           grub_putchar (c);
> +       else if (c == '\r' && buf[i + 1] == '\n')
> +         {
> +           grub_putchar ('\n');
> +           i++;
> +         }
>         else
>           {
>             grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
>
> Thanks,
>
>   


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]