tcl-hacks

Check-in [d6f9265bbe]
Login

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

Overview
Comment:boot.tcl can now pass args to a script correctly, tclish likes this
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tclish-args
Files: files | file ages | folders
SHA1:d6f9265bbe876305171621fdb5416fe202be817e
User & Date: aspect 2018-12-11 07:06:25
Context
2018-12-11
07:07
merge tclish-args, which includes commits unrelated to its topic Leaf check-in: 0227bf5899 user: aspect tags: trunk
07:06
boot.tcl can now pass args to a script correctly, tclish likes this Leaf check-in: d6f9265bbe user: aspect tags: tclish-args
2018-07-29
15:55
provide close, reject unused args from serve check-in: 6ead9e4e36 user: aspect tags: tclish-args
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to bin/tclish.

91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
...
113
114
115
116
117
118
119

120
121
122
123
124
125
126
127
                            -prompt $prompt \
                            -completer [callback complete-word] \
        ;#

        finally [callback getline destroy]

        foreach cmd $cmds {
            getline insert $cmd\n
            try {
                uplevel #0 $cmd
            } on ok {res opt} {
                if {$res eq ""} continue
                puts [tty::attr bold]\ [list $res][tty::attr]
            } on error {res opt} {
                puts [tty::attr fg red bold]\ $res[tty::attr]
            }
        }

        while 1 {
            set input [getline getline]             ;# can return -code break/continue
            try {
                uplevel #0 $input
................................................................................
            } on ok {res opt} {
                if {$res eq ""} continue
                puts [tty::attr bold]\ [list $res][tty::attr]
            } on error {res opt} {
                puts [tty::attr fg red bold]\ $res[tty::attr]
            }
        }

    }

    coroutine Main try {
        tclish::main {*}$::argv
        exit
    }
    vwait forever
}







|




|

|







 







>








91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
                            -prompt $prompt \
                            -completer [callback complete-word] \
        ;#

        finally [callback getline destroy]

        foreach cmd $cmds {
            puts "# % $cmd"
            try {
                uplevel #0 $cmd
            } on ok {res opt} {
                if {$res eq ""} continue
                puts #\ [tty::attr bold][list $res][tty::attr]
            } on error {res opt} {
                puts #\ [tty::attr fg red bold]$res[tty::attr]
            }
        }

        while 1 {
            set input [getline getline]             ;# can return -code break/continue
            try {
                uplevel #0 $input
................................................................................
            } on ok {res opt} {
                if {$res eq ""} continue
                puts [tty::attr bold]\ [list $res][tty::attr]
            } on error {res opt} {
                puts [tty::attr fg red bold]\ $res[tty::attr]
            }
        }
        puts ""
    }

    coroutine Main try {
        tclish::main {*}$::argv
        exit
    }
    vwait forever
}

Changes to boot.tcl.

5
6
7
8
9
10
11

12
13
14
15
16
17
18
19
20
21
22
23

proc boot {args} [format {
    {*}$args [list lappend auto_path %1$s]
    {*}$args [list ::tcl::tm::path add %1$s]
} [list [file normalize [info script]/../modules]]]
boot eval
package provide boot 0.1


if {$::argv ne ""} {
    proc info_cmdline {} [list list [info nameofexe] $::argv0 $::argv]      ;# hack for restartability
    set ::argv [lassign $::argv ::argv0]
    source $::argv0
} else {
    return
    # async repl:
    package require repl
    coroutine main repl::chan stdin stdout stderr
    trace add command main delete {unset ::forever; #}
    vwait forever
}








>
|
|
|
|
|
|
|
|
|
|
|
|
>
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
proc boot {args} [format {
    {*}$args [list lappend auto_path %1$s]
    {*}$args [list ::tcl::tm::path add %1$s]
} [list [file normalize [info script]/../modules]]]
boot eval
package provide boot 0.1

if {[info exists ::argv0] && ($::argv0 eq [info script])} {
    if {$::argv ne ""} {
        proc info_cmdline {} [list list [info nameofexe] $::argv0 $::argv]      ;# hack for restartability
        set ::argv [lassign $::argv ::argv0]
        source $::argv0
    } else {
        return
        # async repl:
        package require repl
        coroutine main repl::chan stdin stdout stderr
        trace add command main delete {unset ::forever; #}
        vwait forever
    }
}