]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
Added shell1 argument to shellify_pipe
authorCheng-Ling Lai <jamesljlster@gmail.com>
Tue, 9 Dec 2025 06:08:31 +0000 (14:08 +0800)
committerCheng-Ling Lai <jamesljlster@gmail.com>
Tue, 9 Dec 2025 07:08:24 +0000 (15:08 +0800)
client/snbk/Shell.cc
client/snbk/Shell.h
client/snbk/TheBigThing.cc

index d9bfb95409745a2c39db6ef4f2231183eef9a50b..319eb0592e34d6da2585b2697ce96e3d9bee83e7 100644 (file)
@@ -81,29 +81,28 @@ namespace snapper
        __builtin_unreachable();
     }
 
-
-    SystemCmd::Args
-    shellify_pipe(const SystemCmd::Args& args1, const Shell& shell2, const SystemCmd::Args& args2)
+    string _wrap_shell_args(const Shell& shell, const SystemCmd::Args& args)
     {
-       string tmp1 = quote(args1);
-       string tmp2 = quote(args2);
-
-       switch (shell2.mode)
+       string tmp = quote(args);
+       switch (shell.mode)
        {
            case Shell::Mode::DIRECT:
-           {
-               return SystemCmd::Args { SH_BIN, "-c", tmp1 + " | " + tmp2 };
-           }
+               return tmp;
 
            case Shell::Mode::SSH:
-           {
-               return SystemCmd::Args { SH_BIN, "-c", tmp1 + " | " + SSH_BIN " " +
-                   quote(shell2.ssh_options) + " " + quote(tmp2) };
-           }
+               return SSH_BIN " " + quote(shell.ssh_options) + " " + quote(tmp);
        }
 
        SN_THROW(Exception("invalid shell mode"));
        __builtin_unreachable();
     }
 
+    SystemCmd::Args
+    shellify_pipe(const Shell& shell1, const SystemCmd::Args& args1,
+                 const Shell& shell2, const SystemCmd::Args& args2)
+    {
+       return { SH_BIN, "-c", _wrap_shell_args(shell1, args1) + " | " +
+           _wrap_shell_args(shell2, args2) };
+    }
+
 }
index d16b6256e6592b17467de8f2022290c3b6fa3b4b..5fbc84f263de85927088cb804cbf670d79ba6038 100644 (file)
@@ -54,7 +54,8 @@ namespace snapper
 
 
     SystemCmd::Args
-    shellify_pipe(const SystemCmd::Args& args1, const Shell& shell2, const SystemCmd::Args& args2);
+    shellify_pipe(const Shell& shell1, const SystemCmd::Args& args1,
+                 const Shell& shell2, const SystemCmd::Args& args2);
 
 }
 
index 398ece697faafcdeecec7857f6967ba8f8dfa36c..413aedc6c62daf0eb9e9fbb333cd023a3b41985f 100644 (file)
@@ -163,7 +163,8 @@ namespace snapper
        y2deb("source: " << cmd3a_args.get_values());
        y2deb("target: " << cmd3b_args.get_values());
 
-       SystemCmd cmd3(shellify_pipe(cmd3a_args, backup_config.get_target_shell(), cmd3b_args));
+       SystemCmd cmd3(shellify_pipe(backup_config.get_source_shell(), cmd3a_args,
+                                    backup_config.get_target_shell(), cmd3b_args));
        if (cmd3.retcode() != 0)
        {
            y2err("command '" << cmd3.cmd() << "' failed: " << cmd3.retcode());