Using wapptclsh instead of standard tclsh
(1.2) By Vetelko (vetelko) on 2024-12-26 07:56:07 edited from 1.1 [link] [source]
Aha moment! It's 5 years, I’ve discovered Wapp :) I don't know how to compile Tcl (currently version 9.0) in a way that the sqlite3 command would be built-in avoiding to call load or package require. So today, I started using the compiled version of wapptclsh instead of the standard tclsh interpreter, even for my simple CLI scripts that aren’t related to web development. This way, I have both Tcl and sqlite in a single binary, with no dependency on any external tcl or sqlite binary libraries—and as a bonus, Wapp, of course! :)
(2) By D. Richard Hipp (drh) on 2024-12-26 11:25:03 in reply to 1.2 [link] [source]
So today, I started using the compiled version of wapptclsh instead of the standard tclsh interpreter, even for my simple CLI scripts that aren’t related to web development.
That's also what I do on the server for SQLite. The website runs in a chroot jail that has access to just two executables: fossil and wapptclsh. (Actually, there are a few more for testing and historical compatibility, but those two are the only ones currently used in production.)
(3) By Sudheer Apte (skiask) on 2025-01-08 15:20:20 in reply to 1.2 [link] [source]
I like wapptclsh for the same reason. But I found a strange thing: when I run "wapptclsh" at the command line, it doesn't give me an interactive prompt. It always expects a filename argument. Looking at the wapptclsh.c.in file, the function wapptclsh_init_proc has a comment that says it should return NULL to run interactively, but the function never returns NULL. It has something to do with how "main_script" is set by the tcl script (wapptclsh.tcl).
(4.9) By Vetelko (vetelko) on 2025-01-10 12:24:44 edited from 4.8 in reply to 3 [source]
Hi Sudheer,
This is done by modifying the wapptclsh.tcl file ... I tried it, got into the shell, but as an eternal Tcl beginner, I hope this is the right way :) Maybe drh will change it the right way in the future.
- It will take you to the shell if called without option or filename
- Has welcome banner
- Handles the -v option or prints usage for any other option.
- Handles non-existent files or files you do not have access rights to.
- The built-in server still works :)
Tip: I'm wrapping shell with rlwrap:
rlwrap -a -- wapptclsh
Gist: wapptclsh.tcl - final