- 论坛徽章:
- 84
|
本帖最后由 yjh777 于 2016-02-19 14:10 编辑
- dict exists [fconfigure stdin] -mode
复制代码 proc
- proc istty {{chann stdin}} {
- dict exists [fconfigure $chann] -mode
- }
复制代码 test- $ cat kkk.tcl
- #!/bin/sh
- # -*- tcl -*-
- # The next line is executed by /bin/sh, but not tcl \
- exec tclsh "$0" ${1+"$@"}
- proc istty {{chann stdin}} {
- dict exists [fconfigure $chann] -mode
- }
- puts [expr {[istty stdin] ? "read from tty" : "doesn't read from tty"}]
- $ ./kkk.tcl
- read from tty
- $ echo | ./kkk.tcl
- doesn't read from tty
- $ ./kkk.tcl < name.txt
- doesn't read from tty
复制代码 |
|