[systemd-devel] shell / systemd config files

Lennart Poettering lennart at poettering.net
Wed Jun 5 23:53:40 PDT 2013


On Mon, 20.05.13 10:28, James Buren (ryu0 at ymail.com) wrote:

> Files such as /etc/machine-info have an incompatibility with systemd in regards to how
> it writes and/or parses them. Take the following sample:
> 
> PRETTY_HOSTNAME="\'\"\$\`\\"
> 
> Systemd will translate this to: '"$`\
> However, the shells bash and dash will translate this to: \'"$`\
> 
> So, it appears to be that systemd is escaping single quotes when the shells themselves
> do not honor it for single quotes here. Thoughts for a solution? I ask because I have to
> write some systemd config files for a distro installer, and cannot use hostnamectl yet.

Hmm, so let me see if I grok this. Bourne shells convert \' inside ""
quotes into \' while systemd converts it to '. Correct?

If that's the case we probably something we should fix. However, to do
that I'd first need to understand the full logic here. For example, what
do bourne shells translate an unknown backslash-escaped sequence to? In
systemd we generally translate this to the same string, but with the \
dropped. The shell appears to simply map it to the exact same string,
with the \ included. 

I guess we should do what we should have done in the first place: find
some docs about the precise Bourne shell escaping rules and reimplement
that. Anyone has some good docs?

James, can you please file a bug on rhbz or fdobz about this?

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list