]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tools: add -n shortcut for --dry-run
authordongshengyuan <545258830@qq.com>
Tue, 28 Jul 2026 11:59:25 +0000 (19:59 +0800)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 Jul 2026 18:47:58 +0000 (03:47 +0900)
Accept -n as a short option for --dry-run in bootctl,
systemd-oomd, systemd-sysusers, and systemd-tmpfiles.

For systemd-repart, make -n equivalent to --dry-run=yes,
while keeping --dry-run=BOOL available.

Follow-up for: 2479f0bb095d9e9f9c56c8110efc87fe0b0f59c0

16 files changed:
NEWS
TODO.md
man/bootctl.xml
man/systemd-oomd.service.xml
man/systemd-repart.xml
man/systemd-sysusers.xml
man/systemd-tmpfiles.xml
src/bootctl/bootctl.c
src/oom/oomd.c
src/repart/repart.c
src/sysusers/sysusers.c
src/tmpfiles/tmpfiles.c
test/units/TEST-22-TMPFILES.15.sh
test/units/TEST-58-REPART.sh
test/units/TEST-74-AUX-UTILS.sysusers.sh
test/units/TEST-87-AUX-UTILS-VM.bootctl.sh

diff --git a/NEWS b/NEWS
index 5e451eb82c4f885471d230938d6d57a1cd54119d..1c6e644137aa586b411b96da730699a378aab058 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -68,6 +68,11 @@ CHANGES WITH 262:
           IPv4ProxyARP=yes but has no effect if IPv4ProxyARP= has been set to
           false. This mirrors the behavior of IPv6ProxyNDPAddress=.
 
+        Changes in various tools:
+
+        * bootctl, systemd-oomd, systemd-repart, systemd-sysusers, and
+          systemd-tmpfiles now accept -n as a short option for --dry-run.
+
         Changes in the TPM Subsystem:
 
         * The way that NvPCRs are anchored has been improved. They are now
diff --git a/TODO.md b/TODO.md
index 190788aab0da2cf7f974f93bf2cb4d64186ede1f..689bcf8549aedde83df71399072bbd886b3e3f07 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -2739,7 +2739,6 @@ SPDX-License-Identifier: LGPL-2.1-or-later
   - teach tmpfiles.d m/M to move / atomic move + symlink old -> new
   - add new line type for setting btrfs subvolume attributes (i.e. rw/ro)
   - tmpfiles: add new line type for setting fcaps
-  - add -n as shortcut for --dry-run in tmpfiles & sysusers & possibly other places
   - add new line type for moving files from some source dir to some
     target dir. then use that to move sysexts/confexts and stuff from initrd
     tmpfs to /run/, so that host can pick things up.
index bf5d2bf23098406d15af3c3df8966302cb6acada..ab003ddaf10c51871088fb1165fc4b0062696571 100644 (file)
       </varlistentry>
 
       <varlistentry>
+        <term><option>-n</option></term>
         <term><option>--dry-run</option></term>
         <listitem><para>Dry run for <option>unlink</option> and <option>cleanup</option>.</para>
 
         <para>In dry run mode, the unlink and cleanup operations only print the files that would get deleted
-        without actually deleting them.</para>
+        without actually deleting them. The short option <option>-n</option> was added in version 262.</para>
 
         <xi:include href="version-info.xml" xpointer="v253"/></listitem>
       </varlistentry>
index 9d04c9da98df58c005480e58e8f5c2a344764dc2..9c735a9383e941e6b0ae220396fc22b30c1a676c 100644 (file)
 
     <variablelist>
       <varlistentry>
+        <term><option>-n</option></term>
         <term><option>--dry-run</option></term>
 
         <listitem><para>Do a dry run of <command>systemd-oomd</command>: when a kill is triggered, print it
-        to the log instead of killing the cgroup.</para>
+        to the log instead of killing the cgroup. The short option <option>-n</option> was added in
+        version 262.</para>
 
         <xi:include href="version-info.xml" xpointer="v253"/></listitem>
       </varlistentry>
index fa7b282bc0e2c6c5c9a4555eb01e83aa9b459bae..c8955e8ee235fa98112e472c6555d3d8b648e9ec 100644 (file)
 
     <variablelist>
       <varlistentry>
+        <term><option>-n</option></term>
         <term><option>--dry-run=</option></term>
 
         <listitem><para>Takes a boolean. If this switch is not specified, <option>--dry-run=yes</option> is
         the implied default. Controls whether <filename>systemd-repart</filename> executes the requested
         re-partition operations or whether it should only show what it would do. Unless
         <option>--dry-run=no</option> is specified <filename>systemd-repart</filename> will not actually
-        touch the device's partition table.</para>
+        touch the device's partition table. The short option <option>-n</option> is equivalent to
+        <option>--dry-run=yes</option> and was added in version 262.</para>
 
         <xi:include href="version-info.xml" xpointer="v245"/></listitem>
       </varlistentry>
index c7210d13cc3a246c13526c3fd10d36e0e8ea9a4a..6a6d8c907dba63a37cd51fcdf8b2210c6b92e136 100644 (file)
       </varlistentry>
 
       <varlistentry>
+        <term><option>-n</option></term>
         <term><option>--dry-run</option></term>
         <listitem><para>Process the configuration and figure out what entries would be created, but do not
-        actually write anything.</para>
+        actually write anything. The short option <option>-n</option> was added in version 262.</para>
 
         <xi:include href="version-info.xml" xpointer="v250"/></listitem>
       </varlistentry>
index 8a4e56cc134c2257e54105d8302cf4b5de96b991..4fd276019dc7d30e16851b3bb4b8dcb5f0588ddc 100644 (file)
       </varlistentry>
 
       <varlistentry>
+        <term><option>-n</option></term>
         <term><option>--dry-run</option></term>
         <listitem><para>Process the configuration and print what operations would be performed, but do not
-        actually change anything in the file system.</para>
+        actually change anything in the file system. The short option <option>-n</option> was added in
+        version 262.</para>
 
         <xi:include href="version-info.xml" xpointer="v256"/></listitem>
       </varlistentry>
index 7956b01ffcfb6a67a9eebf4e97e8a70f81a6a1b4..d28b0f3f3e405413a18940a768f8afc3fd326d66 100644 (file)
@@ -612,7 +612,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
                                 return r;
                         break;
 
-                OPTION_LONG("dry-run", NULL, "Dry run (unlink and cleanup)"):
+                OPTION('n', "dry-run", NULL, "Dry run (unlink and cleanup)"):
                         arg_dry_run = true;
                         break;
 
index 62eecfc065c6583b8ad08380c391958f644fb224..7f1a4d0550c1ad971cd7302becded3708c68103f 100644 (file)
@@ -62,8 +62,8 @@ static int parse_argv(int argc, char *argv[]) {
                 OPTION_COMMON_VERSION:
                         return version();
 
-                OPTION_LONG("dry-run", NULL,
-                            "Only print destructive actions instead of doing them"):
+                OPTION('n', "dry-run", NULL,
+                       "Only print destructive actions instead of doing them"):
                         arg_dry_run = true;
                         break;
 
index ae41fc0d2e524ea46ee5275b940af915c9e4eb4b..77fa5b7c3bd37e7e6348417dfa78916da6998fad 100644 (file)
@@ -10251,6 +10251,10 @@ static int parse_argv(int argc, char *argv[]) {
 
                 OPTION_GROUP("Operation"): {}
 
+                OPTION_SHORT('n', NULL, "Run dry-run operation"):
+                        arg_dry_run = true;
+                        break;
+
                 OPTION_LONG("dry-run", "BOOL",
                             "Whether to run dry-run operation"):
                         r = parse_boolean_argument("--dry-run=", opts.arg, &arg_dry_run);
index 8eb1ae13c597a47f089f66eba6197308fe6634d0..9c52bce66bd7821556b7256ab71de608061a226f 100644 (file)
@@ -2182,7 +2182,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
                         arg_replace = opts.arg;
                         break;
 
-                OPTION_LONG("dry-run", NULL, "Just print what would be done"):
+                OPTION('n', "dry-run", NULL, "Just print what would be done"):
                         arg_dry_run = true;
                         break;
 
index 464384b22bd9ffaeb68cf1472693505c763ca660..28a4c9a98705477b86c818e3ab4a76fc21877330 100644 (file)
@@ -4622,7 +4622,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) {
                         arg_replace = opts.arg;
                         break;
 
-                OPTION_LONG("dry-run", NULL, "Just print what would be done"):
+                OPTION('n', "dry-run", NULL, "Just print what would be done"):
                         arg_dry_run = true;
                         break;
 
index 78be11357df4ea75ea67416d58c7748950ce8110..5080e85c1725f0711921ea1ef1e67e5ffd0a9b5f 100755 (executable)
@@ -13,7 +13,7 @@ home='/somewhere'
 dst='/tmp/L/1'
 src="$home"
 HOME="$home" \
-systemd-tmpfiles --dry-run --create - <<EOF
+systemd-tmpfiles -n --create - <<EOF
 L     $dst    - - - - %h
 EOF
 test ! -h "$dst"
index dbc5017d28698fca66b8ebf98d5355cebf5f68b0..3df437ea4fda09dd176b26b9fdb0d53030049f49 100755 (executable)
@@ -249,7 +249,7 @@ PaddingMinBytes=92M
 EOF
 
     systemd-repart --definitions="$defs" \
-                   --dry-run=yes \
+                   -n \
                    --seed="$seed" \
                    --include-partitions=home,swap \
                    "-"
index 3322d337d8f9c031a7ba02588661df5ac26cca3d..f97058dd4335313231d5d454e006385680ff7003 100755 (executable)
@@ -34,7 +34,7 @@ root="$(mktemp -d)"
 cred="$(mktemp -d)"
 mkdir -p "$root/etc"
 printf 'relative-shell' >"$cred/passwd.shell.creduser"
-(! env CREDENTIALS_DIRECTORY="$cred" systemd-sysusers --dry-run --root="$root" --inline 'u creduser 999 "Cred User" / -')
+(! env CREDENTIALS_DIRECTORY="$cred" systemd-sysusers -n --root="$root" --inline 'u creduser 999 "Cred User" / -')
 (! env CREDENTIALS_DIRECTORY="$cred" systemd-sysusers --root="$root" --inline 'u creduser 999 "Cred User" / -')
 (! grep -F creduser "$root/etc/passwd" >/dev/null 2>&1)
 rm -rf "$root" "$cred"
index c91211e8f8f48ce9325fb9ada7355fc2b095c2b4..b35ab3e695fd952c18a4db7b597f5750f88f141c 100755 (executable)
@@ -619,7 +619,7 @@ EOF
     test -f "$ESP/$TOKEN/testuki.efi"
 
     # --- Test 5: --dry-run leaves everything in place ---
-    "${BOOTCTL[@]}" --dry-run unlink "${TOKEN}-commit_30.conf"
+    "${BOOTCTL[@]}" -n unlink "${TOKEN}-commit_30.conf"
     test -f "$ESP/loader/entries/${TOKEN}-commit_30.conf"
     test -f "$ESP/$TOKEN/testuki.efi"