Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 315621

Summary: eutils.eclass: make_desktop_entry() could use 'printf %b' for 'fields' arg
Product: Gentoo Linux Reporter: Michał Górny <mgorny>
Component: EclassesAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED FIXED    
Severity: enhancement CC: pchrist
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-04-16 15:56:57 UTC
Currently, the 'fields' argument to make_desktop_entry() has to be specified as printf format string. I guess this is because it is supposed to support escape sequences like '\n'. This has the disadvantage that additionally all occurences of '%' have to be escaped.

As it's impossible to pass any additional args to that printf invocation, I don't see a reason why we should require the arg being a printf format string. We could use '%b' conversion specifier instead, which does parse all escape sequences in the argument. This way is more formally corect.

And as the possibility of having such '%'-chars in current 'fields' arg values tends to zero and the help message lacks the explicit warning about having to escape them, I guess it should be feasible to change this behaviour without keeping backwards compatibility.
Comment 1 SpanKY gentoo-dev 2010-04-19 19:26:34 UTC
i'm guessing you're suggesting:
-       [[ -n ${fields} ]] && printf "${fields}\n" >> "${desktop}"
+       [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}"

that should be fine
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-04-19 19:44:47 UTC
Yes, that's what I meant.
Comment 3 SpanKY gentoo-dev 2010-04-19 19:55:03 UTC
done then, thanks

http://sources.gentoo.org/eclass/eutils.eclass?r1=1.341&r2=1.342
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-04-19 20:06:28 UTC
I guess you should update the description to be more precise too.
Comment 5 SpanKY gentoo-dev 2010-04-19 20:14:00 UTC
meh