tcl-hacks

Check-in [b4e24a23f3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:simpler isatty
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tclish-args
Files: files | file ages | folders
SHA1:b4e24a23f3e13fcd01b24cfc9257631711aced61
User & Date: aspect 2018-07-28 05:55:05
Context
2018-07-29
15:35
add minhttpd.tm: as tiny as a useful httpd module can be check-in: 904a0d12e2 user: aspect tags: tclish-args
2018-07-28
05:55
simpler isatty check-in: b4e24a23f3 user: aspect tags: tclish-args
2018-07-26
14:59
tclish taking arguments: will require fixing boot.tcl's argv/0 handling check-in: 37c5eb27dc user: aspect tags: tclish-args
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to hacks/cuppa/tpc.tcl.

20
21
22
23
24
25
26
27
28
29
30






31
32
33
34
35
36
37
..
94
95
96
97
98
99
100





101
102
103
104
105
106
107
108
#   - put commands into a namespace with docs
# [ ] modularise and use appdirs
# [ ] parse tclenv.txt -> uninstall
#   - empty interp
# [ ] assemble & distribute
# [ ] isatty() ?
#
# teaparty synthesises a pkgIndex.tcl for tm's.  I don't wanna do that, so
# install needs to know about libpath + tmpath.
#
# different path for native libs?  hm?  good for xplat starkits.






#
# Teapot deficiencies:  by understanding and consuming these, I can define & serve something better
#   * metadata (requires) is only available embedded - in text, zip or vfs-in-exe (!)
#   * text/binary only known from http response
#   * extension must be inferred (particularly windows applications!)
#   * no incremental index updates
# Some of these could be read from HTML data, but not reliably
................................................................................

proc log {text} {
    puts stderr "# $text"
}

proc isatty {} {
    # unix:





    expr {![catch {exec sh -c {stty <&1} <@stdin >@stdout}]}
}

proc geturl {url} {
    set redirs 2
    while {1} {
        set tok [http::geturl $url]
        try {







|
<

|
>
>
>
>
>
>







 







>
>
>
>
>
|







20
21
22
23
24
25
26
27

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
..
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#   - put commands into a namespace with docs
# [ ] modularise and use appdirs
# [ ] parse tclenv.txt -> uninstall
#   - empty interp
# [ ] assemble & distribute
# [ ] isatty() ?
#
# teaparty synthesises a pkgIndex.tcl for tm's.  I don't wanna do that, so install needs to know about libpath + tmpath.

#
# different path for native libs?  hm?  good for xplat starkits.  But makes vfs maintenance awful, so don't
#
# TODO:
#   * install directory names should not contain ::
#   * all repo commands should take a dict; {name dict} is awkward
#   * might as well support uninstall
#   * mkvfs for non-native arch
#
# Teapot deficiencies:  by understanding and consuming these, I can define & serve something better
#   * metadata (requires) is only available embedded - in text, zip or vfs-in-exe (!)
#   * text/binary only known from http response
#   * extension must be inferred (particularly windows applications!)
#   * no incremental index updates
# Some of these could be read from HTML data, but not reliably
................................................................................

proc log {text} {
    puts stderr "# $text"
}

proc isatty {} {
    # unix:
    expr {![catch {chan configure stdout -mode}]}
    # doesn't work on windows (according to wine).  But wine+tclkit does get
    #  -encoding unicode ... if tty  (unicode? what fucking sort of encoding is that?)
    #  -encoding [encoding system] ... if redirected
    # uglier alternative:
    #expr {![catch {exec sh -c {stty <&1 > /dev/null} <@stdin >@stdout}]}
}

proc geturl {url} {
    set redirs 2
    while {1} {
        set tok [http::geturl $url]
        try {