Hello,

Last weekend, the Asturian team found a bug in Grub. Thanks for the
debugging. The string that appears in grub.cfg for "Loading the initram"
in Asturian is "Cargando'l discu RAM inicial...". So grub.cfg looks
like:
        echo    Cargando'l discu RAM inicial...

This is syntactically invalid because the character "'".

Easy work around: generate the line like:
        echo    "Cargando'l discu RAM inicial..."

New problem: in some language, this string could have a double quote
inside.

New solution: escape the double quotes strings when they are used in
gettext and always use these strings with double quotes.

See the attached patch.

I'm not convinced of the patch, does anybody has a cleaner idea/patch?

Cheers,

PS: I haven't double checked, but lines like initrd  
/boot/initrd.img-2.6.32-18-generic will fail if the path has spaces. I'll 
address it in the future.

PS2: I haven't checked the patch yet, let's comment on the idea. Before
committing I would write the changelog and check it.

-- 
Carles Pina i Estany
        http://pinux.info
=== modified file 'util/grub-mkconfig_lib.in'
--- util/grub-mkconfig_lib.in	2010-02-25 13:30:50 +0000
+++ util/grub-mkconfig_lib.in	2010-04-10 20:47:18 +0000
@@ -188,3 +188,8 @@ version_find_latest ()
   done
   echo "$a"
 }
+
+gettext_escape_double_quotes ()
+{
+  echo -n $(gettext $@) | sed 's/\"/\\\"/'
+}

=== modified file 'util/grub.d/10_linux.in'
--- util/grub.d/10_linux.in	2010-04-08 09:54:44 +0000
+++ util/grub.d/10_linux.in	2010-04-10 20:49:06 +0000
@@ -56,9 +56,9 @@ linux_entry ()
   recovery="$3"
   args="$4"
   if ${recovery} ; then
-    title="$(gettext "%s, with Linux %s (recovery mode)")"
+    title="$(gettext_escape_double_quotes "%s, with Linux %s (recovery mode)")"
   else
-    title="$(gettext "%s, with Linux %s")"
+    title="$(gettext_escape_double_quotes "%s, with Linux %s")"
   fi
   printf "menuentry \"${title}\" ${CLASS} {\n" "${os}" "${version}"
   save_default_entry | sed -e "s/^/\t/"
@@ -83,12 +83,12 @@ EOF
   fi
   printf '%s\n' "${prepare_boot_cache}"
   cat << EOF
-	echo	$(printf "$(gettext "Loading Linux %s ...")" ${version})
+	echo	\"$(printf "$(gettext_escape_double_quotes "Loading Linux %s ...")" ${version})\"
 	linux	${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
 EOF
   if test -n "${initrd}" ; then
     cat << EOF
-	echo	$(gettext "Loading initial ramdisk ...")
+	echo	\"$(gettext_escape_double_quotes "Loading initial ramdisk ...")\"
 	initrd	${rel_dirname}/${initrd}
 EOF
   fi

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to