Skip to content

Commit

Permalink
fix echo command
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcvr committed Nov 1, 2024
1 parent c22cb81 commit c9fa9fc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ func main() {
}

if cmd != "" {
cmd0 := sess.Command()[0]
resp := makeResponse(cmd0)
resp := makeResponse(cmd)
Try(sess.Write([]byte(resp)))
slog.Debug("cmd", "sent", resp)
return
Expand Down Expand Up @@ -174,8 +173,11 @@ func makeResponse(cmd string) string {
resp, ok := cmdResponses[list[0]]
if !ok {
if list[0] == "echo" {
resp = strings.ReplaceAll(list[1], "'", "")
resp = strings.ReplaceAll(resp, `"`, "") + "\n"
if len(list) > 1 {
resp = strings.ReplaceAll(list[1], "'", "")
resp = strings.ReplaceAll(resp, `"`, "")
}
resp += "\n"
} else {
resp = fmt.Sprintf("%s: command not found\n", cmd)
}
Expand Down

0 comments on commit c9fa9fc

Please sign in to comment.