Usually in almost all circumstances /dev/sdterr is a TTY; meanwhile /dev/stdin and/or /dev/stdout can be redirected to files or pipes. (In fact if /dev/stderr is not a TTY, most likely the other two are inherited or poorly set-up, and this process isn't meant to handle the terminal.)
At the moment liner checks if any of stdin or stdout are redirected, and if so degrades to a "dumb" terminal:
|
s.terminalSupported = TerminalSupported() |
|
if m, err := TerminalMode(); err == nil { |
|
s.origMode = *m.(*termios) |
|
} else { |
|
s.inputRedirected = true |
|
} |
|
if _, err := getMode(syscall.Stdout); err != 0 { |
|
s.outputRedirected = true |
|
} |
|
if s.inputRedirected && s.outputRedirected { |
|
s.terminalSupported = false |
|
} |
My proposal (which I could implement if accepted) is to either:
- (preferably) always use
/dev/stderr for both input and output and check that itself is a TTY;
- alternatively if either
stdin or stdout seems to be redirected, check if perhaps stderr is a TTY and use that;
I currently use liner in such a scenario, and for the moment I replace syscall.Stdin / syscall.Stdout with syscall.Stderr and it seems to do the trick. However this hack works in my limited case, but as said I'm willing to code this proposed feature.
Usually in almost all circumstances
/dev/sdterris a TTY; meanwhile/dev/stdinand/or/dev/stdoutcan be redirected to files or pipes. (In fact if/dev/stderris not a TTY, most likely the other two are inherited or poorly set-up, and this process isn't meant to handle the terminal.)At the moment
linerchecks if any ofstdinorstdoutare redirected, and if so degrades to a "dumb" terminal:liner/input.go
Lines 38 to 49 in abb5e9d
My proposal (which I could implement if accepted) is to either:
/dev/stderrfor both input and output and check that itself is a TTY;stdinorstdoutseems to be redirected, check if perhapsstderris a TTY and use that;I currently use
linerin such a scenario, and for the moment I replacesyscall.Stdin/syscall.Stdoutwithsyscall.Stderrand it seems to do the trick. However this hack works in my limited case, but as said I'm willing to code this proposed feature.