diff --git a/tools/cmd/ssh/config.go b/tools/cmd/ssh/config.go index 6e88a5d2e..10fb2114a 100644 --- a/tools/cmd/ssh/config.go +++ b/tools/cmd/ssh/config.go @@ -180,7 +180,7 @@ func get_arcname(loc, dest, home string) (arcname string) { } func ParseCopyInstruction(spec string) (ans []*CopyInstruction, err error) { - args, err := shlex.Split(spec) + args, err := shlex.Split("copy " + spec) if err != nil { return nil, err } diff --git a/tools/cmd/ssh/config_test.go b/tools/cmd/ssh/config_test.go index 7a3f15386..a1d454d1e 100644 --- a/tools/cmd/ssh/config_test.go +++ b/tools/cmd/ssh/config_test.go @@ -20,8 +20,8 @@ func TestSSHConfigParsing(t *testing.T) { username := "" conf := "" for_python := false + cf := filepath.Join(tdir, "ssh.conf") rt := func(expected_env ...string) { - cf := filepath.Join(tdir, "ssh.conf") os.WriteFile(cf, []byte(conf), 0o600) c, err := load_config(hostname, username, nil, cf) if err != nil { @@ -73,4 +73,33 @@ func TestSSHConfigParsing(t *testing.T) { rt(`export ["a"]`) conf = "env a" rt(`unset ["a"]`) + + ci, err := ParseCopyInstruction("--exclude moose --dest=target " + cf) + if err != nil { + t.Fatal(err) + } + diff := cmp.Diff("home/target", ci[0].arcname) + if diff != "" { + t.Fatalf("Incorrect arcname:\n%s", diff) + } + diff = cmp.Diff(cf, ci[0].local_path) + if diff != "" { + t.Fatalf("Incorrect local_path:\n%s", diff) + } + diff = cmp.Diff([]string{"moose"}, ci[0].exclude_patterns) + if diff != "" { + t.Fatalf("Incorrect excludes:\n%s", diff) + } + ci, err = ParseCopyInstruction("--glob " + filepath.Join(filepath.Dir(cf), "*.conf")) + if err != nil { + t.Fatal(err) + } + diff = cmp.Diff(cf, ci[0].local_path) + if diff != "" { + t.Fatalf("Incorrect local_path:\n%s", diff) + } + if len(ci) != 1 { + t.Fatal(ci) + } + }