Skip to content

Commit 15a6a51

Browse files
committed
Fix RemoteCommand usage with bootstrap.py and bootstrap.sh not exiting after RemoteCommand
1 parent a47093a commit 15a6a51

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

kittens/ssh/main.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,12 @@ func prepare_remote_cmd(cd *connection_data) string {
418418

419419
remote_command := cd.ssh_config.RemoteCommand
420420
if cd.script_type == "py" {
421-
return base64.RawStdEncoding.EncodeToString(utils.UnsafeStringToBytes(remote_command))
421+
return base64.StdEncoding.EncodeToString(utils.UnsafeStringToBytes(remote_command))
422422
}
423-
return remote_command
423+
if remote_command == "" {
424+
return ""
425+
}
426+
return remote_command + "\n\nexit"
424427
}
425428

426429
var data_shm shm.MMap
@@ -435,6 +438,7 @@ func prepare_script(script string, replacements map[string]string) string {
435438
if _, found := replacements["REMOTE_CMD"]; !found {
436439
replacements["REMOTE_CMD"] = ""
437440
}
441+
replacements["HAS_REMOTE_CMD"] = utils.IfElse(replacements["REMOTE_CMD"] == "", "n", "y")
438442
keys := utils.Keys(replacements)
439443
for i, key := range keys {
440444
keys[i] = "\\b" + key + "\\b"
@@ -640,7 +644,6 @@ func run_ssh(ssh_args, server_args, found_extra_args []string, ssh_config_channe
640644
}
641645
insertion_point := len(cmd)
642646
cmd = append(cmd, "--", hostname)
643-
cmd = slices.Insert(cmd, insertion_point, "-o", "RemoteCommand=none")
644647
uname, hostname_for_match := get_destination(hostname)
645648
overrides, literal_env, err := parse_kitten_args(found_extra_args, uname, hostname_for_match)
646649
if err != nil {

0 commit comments

Comments
 (0)