Systemd string escaping

etcd, systemd

Solution

systemd-escape '\"a fun thing"\' 

output: `\x5c\x22a\x20fun\x20thing\x22\x5c`

[Service]
ExecStart=/bin/sh -c 'echo "\x5c\x22a\x20fun\x20thing\x22\x5c"'

will print `a fun thing`

Problem

If I run this command ``` /bin/bash -c 'while true;do /usr/bin/etcdctl set my-container "{\"host\": \"1\", \"port\": $(/usr/bin/docker port my-container 5000 | cut -d":" -f2)}" --ttl 60;sleep 45;done' ``` I get back from etcd what I expect {"host":"1", "port":49155} But if I put it in a systemd file ``` ExecStart=/bin/bash -c 'while true;do /usr/bin/etcdctl set my-container "{\"host\": \"1\", \"port\": $(/usr/bin/docker port my-container 5000 | cut -d":" -f2)}" --ttl 60;sleep 45;done' ``` I get back {host:1, port:49155} Any idea of why the escaping is different inside of the file? How can I fix it? Thanks!!

Original source