Skip to content

Commit

Permalink
If no command is passed, spawn a shell.
Browse files Browse the repository at this point in the history
Fixes #9
  • Loading branch information
1player committed Jul 27, 2022
1 parent 7e6cf8d commit 6fb65d0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ func runCommandSync(args []string, allocatePty bool) (int, error) {
}

func parseArguments() {
const USAGE_PREAMBLE = `Usage: %s [options] COMMAND [arguments...]
const USAGE_PREAMBLE = `Usage: %s [options] [ COMMAND [ arguments... ] ]
If COMMAND is not set, spawn a shell on the host.
Accepted options:
`
Expand Down Expand Up @@ -145,6 +147,11 @@ func main() {
if basename == OUR_BASENAME {
parseArguments()
command = flag.Args()

// If no command is given, spawn a shell
if len(command) == 0 {
command = []string{"sh", "-c", "$SHELL"}
}
} else {
command = append([]string{basename}, os.Args[1:]...)
}
Expand Down

0 comments on commit 6fb65d0

Please sign in to comment.