]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
specifier: use %q for pretty hostname 23024/head
authorLennart Poettering <lennart@poettering.net>
Fri, 8 Apr 2022 16:09:18 +0000 (18:09 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 8 Apr 2022 16:17:50 +0000 (18:17 +0200)
%R is already used in service manager specifier expansion (cgroup root),
hence use a different char, that was so far not used.

Follow-up for: 6ceb0a4094908dd213a78b9f6d0c59a684831ab0

NEWS
man/standard-specifiers.xml
man/systemd.unit.xml
src/shared/specifier.h
src/test/test-specifier.c

diff --git a/NEWS b/NEWS
index c01bcdab45eaebc638dad49667a029a39931dbf5..330d46d1d12c7f7d3a8b2a0fc4b92f413dfc4d55 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -239,7 +239,7 @@ CHANGES WITH 251:
           normalized unit file path, which is particularly useful for symlinked
           unit files.
 
-          The new %R specifier resolves to the pretty hostname
+          The new %q specifier resolves to the pretty hostname
           (i.e. PRETTY_HOSTNAME= from /etc/machine-info).
 
           The new %d specifier resolves to the credentials directory of a
index abbd47f7782a65178863326cfd751b5c22184cfd..e7314b9c4a31372cce4c33f673b0992b8f3c9edd 100644 (file)
     <entry>Short host name</entry>
     <entry>The hostname of the running system, truncated at the first dot to remove any domain component.</entry>
   </row>
-  <row id='R'>
-    <entry><literal>%R</literal></entry>
-    <entry>Pretty host name</entry>
-    <entry>The pretty hostname of the running system, as read from the <varname>PRETTY_HOSTNAME=</varname> field of <filename>/etc/machine-info</filename>. If not set, resolves to the short hostname. See <citerefentry><refentrytitle>machine-info</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
-  </row>
   <row id='m'>
     <entry><literal>%m</literal></entry>
     <entry>Machine ID</entry>
     <entry>Operating system ID</entry>
     <entry>The operating system identifier of the running system, as read from the <varname>ID=</varname> field of <filename>/etc/os-release</filename>. See <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
   </row>
+  <row id='q'>
+    <entry><literal>%q</literal></entry>
+    <entry>Pretty host name</entry>
+    <entry>The pretty hostname of the running system, as read from the <varname>PRETTY_HOSTNAME=</varname> field of <filename>/etc/machine-info</filename>. If not set, resolves to the short hostname. See <citerefentry><refentrytitle>machine-info</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
+  </row>
   <row id='T'>
     <entry><literal>%T</literal></entry>
     <entry>Directory for temporary files</entry>
index 7a611dc93f791ad0c3bc4274b851ec63ec242eb6..cd033ac52e198ff0863c4397ac907f01a37dade3 100644 (file)
@@ -2097,7 +2097,7 @@ Note that this setting is <emphasis>not</emphasis> influenced by the <varname>Us
           <row>
             <!-- We do not use the common definition from standard-specifiers.xml here since we want a
                  slightly more verbose explanation here, referring to the reload cycle. -->
-            <entry><literal>%R</literal></entry>
+            <entry><literal>%q</literal></entry>
             <entry>Pretty host name</entry>
             <entry>The pretty hostname of the running system at the point in time the unit configuration is loaded, as read from the <varname>PRETTY_HOSTNAME=</varname> field of <filename>/etc/machine-info</filename>. If not set, resolves to the short hostname. See <citerefentry><refentrytitle>machine-info</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
           </row>
index 78b10f846717258e77b01d1f5e1ac128a3a3a92d..ea37e3cef6fec86fcaf89e7bca7be019c32087c3 100644 (file)
@@ -51,6 +51,7 @@ int specifier_var_tmp_dir(char specifier, const void *data, const char *root, co
  * %B: the OS build ID, according to /etc/os-release
  * %H: the hostname of the running system
  * %l: the short hostname of the running system
+ * %q: the 'pretty' hostname as per /etc/machine-info
  * %m: the machine ID of the running system
  * %M: the OS image ID, according to /etc/os-release
  * %o: the OS ID according to /etc/os-release
@@ -76,7 +77,7 @@ int specifier_var_tmp_dir(char specifier, const void *data, const char *root, co
         { 'B', specifier_os_build_id,     NULL }, \
         { 'H', specifier_host_name,       NULL }, \
         { 'l', specifier_short_host_name, NULL }, \
-        { 'R', specifier_pretty_host_name,NULL }, \
+        { 'q', specifier_pretty_host_name,NULL }, \
         { 'm', specifier_machine_id,      NULL }, \
         { 'M', specifier_os_image_id,     NULL }, \
         { 'o', specifier_os_id,           NULL }, \
index 49b4f5a2a33e2a6d50877e985ef5d320591171ad..516502032a78dc0e58499a7b34fe3ab7b8d1d600 100644 (file)
@@ -74,7 +74,7 @@ TEST(specifier_printf) {
         assert_se(streq(w, "xxx a=AAAA b=BBBB e= yyy"));
 
         free(w);
-        r = specifier_printf("machine=%m, boot=%b, host=%H, pretty=%R, version=%v, arch=%a, empty=%e", SIZE_MAX, table, NULL, NULL, &w);
+        r = specifier_printf("machine=%m, boot=%b, host=%H, pretty=%q, version=%v, arch=%a, empty=%e", SIZE_MAX, table, NULL, NULL, &w);
         assert_se(r >= 0);
         assert_se(w);
         puts(w);