Updated 2017-06-04 10:09:25 by dbohdan
What eltclsh
Where http://homepages.laas.fr/mallet/soft/shell/eltclsh (latest version)
https://www.openrobots.org/wiki/eltclsh (outdated)
Description The editline tcl shell is an interactive shell for the Tcl interpreter. It provides command line editing, history browsing, and variable/command completion thanks to the features of editline (aka libedit). The completion engine is programmable and comes with built-in completion for all of Tk. The package also includes elwish, an interactive interpreter for Tcl/Tk that corresponds to wish.
Currently at version 1.16.
Updated 2017-01-16

Summary  edit

aspect: The eltclsh distribution packages eltclsh as an extension, which the binary simply package requires into the interpreter it creates. The extension includes a signal handler and the editline binding itself.

Building  edit

On FreeBSD you will need gmake, and to touch eltclsh.1.cat in the unpacked eltclsh-1.9 directory before running
./configure --with-tk=no; gmake install clean

When built for Tcl/Tk 8.5:

  • eltclsh operated correctly;
  • elwish did not show the initial Tk window (eltclsh with package require Tk did). You can reveal with window with wm deiconify .

On a Debian-based machine building eltclsh successfully required installing libxss-dev.

Use  edit

To make eltclsh your completion engine for the standard tclsh in interactive mode (similarly to how it is done on tclreadline), simply add something like the following to your tclshrc:
if {$tcl_interactive} {
    if {![file exists /usr/local/share/eltcl/pkgIndex.tcl] || [catch {
        lappend ::auto_path /usr/local/share/eltcl
        package require eltclsh
        set ::el::prompt1 {list tclsh [info patchlevel] %}
        set ::el::prompt2 {list tclsh ...... >}
    }]} {
        puts "Failed to load eltclsh!"

If eltclsh can't be loaded, you can try to fall back on tclreadline, or the standard tclsh prompt (which is default behaviour with the above code). The interactive command is eltclsh's equivalent of ::tclreadline::Loop. Loading eltclsh in this manner has at least a few advantages: you don't have to retrain your fingers from typing tclsh, and the same mechanism can work against multiple tclsh versions, without having to link multiple eltclsh binaries.

The eltclsh code is quite tidy and straightforward. Noteworthy is tools/complete.tcl, which sets up the variable ::el::completionPatterns which it uses to do argument completion of core Tcl commands.