From 8d963dabaaba152b995bfc963dd574f69a1ee04a Mon Sep 17 00:00:00 2001
From: Matt Johnston <matt@ucc.asn.au>
Date: Fri, 7 Apr 2023 22:26:32 +0800
Subject: [PATCH] Fix argument handling for args after hostname

sunsetc host -s sftp

would fail before. argh has a "greedy" attribute to handle that
---
 async/examples/sunsetc.rs | 12 +-----------
 async/src/known_hosts.rs  |  1 +
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/async/examples/sunsetc.rs b/async/examples/sunsetc.rs
index b4a36cc..65e61df 100644
--- a/async/examples/sunsetc.rs
+++ b/async/examples/sunsetc.rs
@@ -63,7 +63,7 @@ struct Args {
     /// ssh subsystem (eg "sftp")
     subsystem: Option<String>,
 
-    #[argh(positional)]
+    #[argh(positional, greedy)]
     /// command
     cmd: Vec<String>,
 
@@ -97,22 +97,12 @@ fn parse_args() -> Result<Args> {
     let cmd = in_args.next().expect("command name");
     let mut mangled_args = vec![];
 
-    let mut not_flags = 0;
-
     for a in in_args {
         if a.starts_with("-o") {
             let (o, v) = a.split_at(2);
             mangled_args.push(o.to_string());
             mangled_args.push(v.to_string());
         } else {
-
-            // Flag arguments after the remote command should get escaped
-            if !a.starts_with('-') {
-                not_flags += 1;
-                if not_flags == 2 {
-                    mangled_args.push("--".to_string());
-                }
-            }
             mangled_args.push(a.to_string())
         }
     }
diff --git a/async/src/known_hosts.rs b/async/src/known_hosts.rs
index 0612331..aec4809 100644
--- a/async/src/known_hosts.rs
+++ b/async/src/known_hosts.rs
@@ -101,6 +101,7 @@ pub fn check_known_hosts_file(
             Ok(k) => k,
             Err(e) => {
                 warn!("Unparsed key for {} on line {}:{}", host, p.display(), line);
+                trace!("{e:?}");
                 continue;
             }
         };
-- 
GitLab