Skip to content

Commit

Permalink
add pty flag to force it, if no flag is specified, use the blocklist
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <[email protected]>
  • Loading branch information
89luca89 committed Dec 19, 2022
1 parent 5fafee0 commit 4f85e3e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import (
var Version string = "HEAD"

// blocklist contains the list of programs not working well with an allocated pty.
var blocklist = map[string]bool {
var blocklist = map[string]bool{
"xdg-open": true,
"gio": true,
"gio": true,
}

// Command line options
var flagPty = flag.Bool("pty", false, "Force allocate a pseudo-terminal for the host process")
var flagNoPty = flag.Bool("no-pty", false, "Do not allocate a pseudo-terminal for the host process")
var flagVersion = flag.Bool("version", false, "Show this program's version")
var flagEnvironmentVariables = flag.String("env", "TERM", "Comma separated list of environment variables to pass to the host process.")
Expand Down Expand Up @@ -173,7 +174,12 @@ func main() {
}

// Lookup if this is a blacklisted program, where we won't enable pty.
allocatePty := (!*flagNoPty && !blocklist[command[0]])
allocatePty := !blocklist[command[0]]
if *flagPty {
allocatePty = true
} else if *flagNoPty {
allocatePty = false
}

envsToPassthrough := strings.Split(*flagEnvironmentVariables, ",")

Expand Down

0 comments on commit 4f85e3e

Please sign in to comment.