]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
macros: use here-docs instead of echo (#8480)
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 19 Mar 2018 08:07:44 +0000 (09:07 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 19 Mar 2018 08:07:44 +0000 (17:07 +0900)
It's common for sysusers files to contain quotes (in particular around the
comment/GECOS field), and using echo "..." is very likely to not work properly
in that case. Let's use <<EOF redirection. It's not bulletproof, but should
work in general.

src/core/macros.systemd.in

index 4e27e1b06ab0a8b468923cbc6cd03be862a1c02e..8307712ffed3a9d6fdef6fa47e365dbadfe3c8dd 100644 (file)
@@ -101,7 +101,9 @@ systemd-sysusers %{?*} >/dev/null 2>&1 || : \
 %{nil}
 
 %sysusers_create_inline() \
-echo %{?*} | systemd-sysusers - >/dev/null 2>&1 || : \
+systemd-sysusers - <<SYSTEMD_INLINE_EOF >/dev/null 2>&1 || : \
+%(cat %2) \
+SYSTEMD_INLINE_EOF \
 %{nil}
 
 # This should be used by package installation scripts which require users or
@@ -118,7 +120,9 @@ echo %{?*} | systemd-sysusers - >/dev/null 2>&1 || : \
 #   %files
 #   %{_sysusersdir}/%{name}.conf
 %sysusers_create_package() \
-echo "%(cat %2)" | systemd-sysusers --replace=%_sysusersdir/%1.conf - >/dev/null 2>&1 || : \
+systemd-sysusers --replace=%_sysusersdir/%1.conf - <<SYSTEMD_INLINE_EOF >/dev/null 2>&1 || : \
+%(cat %2) \
+SYSTEMD_INLINE_EOF \
 %{nil}
 
 # This may be used by package installation scripts to create files according to
@@ -135,7 +139,9 @@ echo "%(cat %2)" | systemd-sysusers --replace=%_sysusersdir/%1.conf - >/dev/null
 #   %files
 #   %{_tmpfilesdir}/%{name}.conf
 %tmpfiles_create_package() \
-echo "%(cat %2)" | systemd-tmpfiles --replace=%_tmpfilesdir/%1.conf --create - >/dev/null 2>&1 || : \
+systemd-tmpfiles --replace=%_tmpfilesdir/%1.conf --create - <<SYSTEMD_INLINE_EOF >/dev/null 2>&1 || : \
+%(cat %2) \
+SYSTEMD_INLINE_EOF \
 %{nil}
 
 %sysctl_apply() \