From c217e1fe82f08c00609904c50ec77f366f2fbaf9 Mon Sep 17 00:00:00 2001 From: Andrew Chambers Date: Thu, 24 Jan 2019 14:39:38 +1300 Subject: [PATCH] Add way to fetch the unparsed command string from a session. --- session.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/session.go b/session.go index c3db354..1d4d3a5 100644 --- a/session.go +++ b/session.go @@ -39,6 +39,9 @@ type Session interface { // Exit sends an exit status and then closes the session. Exit(code int) error + // RawCommand returns the command exactly as the client/user specified it. + RawCommand() string + // Command returns a shell parsed slice of arguments that were provided by the // user. Shell parsing splits the command string according to POSIX shell rules, // which considers quoting not just whitespace. @@ -104,6 +107,7 @@ type session struct { winch chan Window env []string ptyCb PtyCallback + rawCmd string cmd []string ctx Context sigCh chan<- Signal @@ -177,6 +181,10 @@ func (sess *session) Environ() []string { return append([]string(nil), sess.env...) } +func (sess *session) RawCommand() string { + return sess.rawCmd +} + func (sess *session) Command() []string { return append([]string(nil), sess.cmd...) }