Check input device is a terminal: Difference between revisions
Content added Content deleted
(→{{header|Ruby}}: Added Ruby Header and sample) |
(Go solution) |
||
Line 67: | Line 67: | ||
C:\test < in.txt |
C:\test < in.txt |
||
Input doesn't come from tty.</pre> |
Input doesn't come from tty.</pre> |
||
=={{header|Go}}== |
|||
{{libheader|Go sub-repositories}} |
|||
<lang go>package main |
|||
import ( |
|||
"code.google.com/p/go.crypto/ssh/terminal" |
|||
"fmt" |
|||
"os" |
|||
) |
|||
func main() { |
|||
if terminal.IsTerminal(int(os.Stdin.Fd())) { |
|||
fmt.Println("Hello terminal") |
|||
} else { |
|||
fmt.Println("Who are you? You're not a terminal.") |
|||
} |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
> hello |
|||
Hello terminal |
|||
> hello </dev/null |
|||
Who are you? You're not a terminal. |
|||
</pre> |
|||
=={{header|Nemerle}}== |
=={{header|Nemerle}}== |