[systemd-devel] shell / systemd config files

Andrey Borzenkov arvidjaar at gmail.com
Thu Jun 6 08:19:32 PDT 2013


В Thu, 6 Jun 2013 08:53:40 +0200
Lennart Poettering <lennart at poettering.net> пишет:

> 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?
> 

Will The Open Group be enough?

--><--

The <backslash> shall retain its special meaning as an escape character (see Escape Character (Backslash)) only when followed by one of the following characters when considered special:

$   `   "   \   <newline>

--><--

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_03

I'm too lazy to look up POSIX online :)


More information about the systemd-devel mailing list