Skip to contentSkip to conversation

print CR as hex in cat command

PATCH In review Christian Franke 2 participants 2 messages Feb 8, 2008 – Feb 9, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 print CR as hex in cat command

Here a small patch for a minor issue:
cat command does not work well for files including '\r' because the previous line may be overwritten. In grub-emu, files with cr/lf line endings are invisible due to ncurses behavior.

Christian

2008-02-08 Christian Franke <[email protected]>

* commands/cat.c (grub_cmd_cat): Print '\r' as hex to avoid overwriting previous output.
* kern/rescue.c (grub_rescue_cmd_cat): Likewise.

commands/cat.c +1 -1
diff -rup grub2.orig/commands/cat.c grub2/commands/cat.c
@@ -50,7 +50,7 @@ grub_cmd_cat (struct grub_arg_list *stat
 	{
 	  unsigned char c = buf[i];
 	  
-	  if (grub_isprint (c) || grub_isspace (c))
+	  if ((grub_isprint (c) || grub_isspace (c)) && c != '\r')
 	    grub_putchar (c);
 	  else
 	    {
kern/rescue.c +1 -1
diff -rup grub2.orig/kern/rescue.c grub2/kern/rescue.c
@@ -151,7 +151,7 @@ grub_rescue_cmd_cat (int argc, char *arg
 	{
 	  unsigned char c = buf[i];
 
-	  if (grub_isprint (c) || grub_isspace (c))
+	  if ((grub_isprint (c) || grub_isspace (c)) && c != '\r')
 	    grub_putchar (c);
 	  else
 	    {
#1 lore raw
Quoted 6 lines · Christian Franke

Here a small patch for a minor issue:
cat command does not work well for files including '\r' because the previous line may be overwritten.
In grub-emu, files with cr/lf line endings are invisible due to ncurses behavior.

Quoted 7 lines

Christian

2008-02-08 Christian Franke <[email protected]>

* commands/cat.c (grub_cmd_cat): Print '\r' as hex to avoid overwriting previous output.
* kern/rescue.c (grub_rescue_cmd_cat): Likewise.

Committed.

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)