Version 22 of tclreadline

Updated 2008-09-06 09:45:16 by FGP

What: tclreadline

 Where: http://tclreadline.sourceforge.net/ 
 Description: Tcl extension binding for GNU readline.  Works with Tcl 8.1,
        as well as itcl.
        Currently at version 2.1.0 .
 Updated: 07/2001
 Contact: mailto:[email protected] 

Johannes Zellner


There is a wiki page on readline

For people having trouble getting this working on Unix type OSes, rlwrap [L1 ] is an alternative. Install rlwrap (it is in most Linux repos) and start tclsh with rlwrap tclsh


JMN 2004-03-20

According to 'requirements' tclreadline works with at least some versions of tcl8.4. I struggled to build tclreadline 2.1.1 on FreeBSD5.1, against tcl8.4.6 only to get a core dump when running ::tclreadline::Loop

I've also tried using rlwrap, which does not appear to run on FreeBSD4.9 and which complains "could not open master pty" on my FreeBSD5.1 box.

Seeing as I really only want the basic up & down arrow cycling through history, and not the fancy readline search & autocompletion and whatever else it may offer - is there some other way I can achieve this functionality in a plain tclsh shell? (I need to run this on plain X-less boxes and ssh sessions.)

It seems to me a very unfortunate lack of cross-platform consistency that the functionality I've always taken for granted on windows boxes doesn't seem to work on Unix-like machines. I understand the gnu readline license is unsuitable for inclusion in TCL, but is there no interest in including some *basic* history editing in tclsh to bring it into line with Windows behaviour?

NEM When you say it works on Windows, you mean in the Tk console, or when running tclsh from the command prompt? If the former, then you can just use tkcon on Unix to get the same behaviour (plus a lot more). When running at the command prompt, you could use the history command. It's not as convenient, but it works. I don't think there is any code for readline style editing for tclsh on any platform, so if it works on Windows I assume it's the windows console which makes it work (somehow).


2004-03-20 SRIV I tried tclreadline and found it a pain to setup. A much easier solution on linux is rlwrap [L2 ]. I stick it on all my linux computers. Since I use tclkit instead of tclsh, I run rlwrap tclkit and I get a % prompt with full readline history, even across invocations. Give it a try. I use it most often while debugging small scripts while logged in to a remote server.


2004-04-22 I wonder how hard it would be to integrate Tecla with the tcl shell? http://www.astro.caltech.edu/~mcs/tecla/

Unlike readline, this software has a BSD-like license. It'd be nice to have this available across all tcl platforms without having to use special wrappers and workarounds - a 'package require' would do I guess, but it'd be better if it just worked and provided a consistent environment even on platforms such as windows which already automatically provide similar console functionality.


tclguy comments on editline vs. readline vs. eltclsh [L3 ]

Is "cle" also in here somewhere?


2007-11-15 Mike

Getting tclreadline (2.1.0) running on Mac OSX is a hassle. After running "./configure --enable-tclshrl" followed by "make", i got errors about "Undefined symbols ...". To fix it you need to do the following:

  • After you have made sure you have a recent version of the readline library (I use 5.2), you will need to make sure that the symbolic link under /usr/lib/libreadline.dylib is pointing to the right location (originally it was pointing to /usr/lib/libedit.dylib).

If you enable tclreadline in your tclsh and get an "alloc: invalid block: ..." error, then you will have to do the following:

  • Edit tclreadline.c file and rename all MALLOC to malloc and FREE to free (and remove the macros MALLOC and FREE)

2007-12-24 PYL

  • Apparently /usr/lib/libedit.dylib is or contains libreadline as a 'nm -o /usr/lib/libedit.dylib' will show you...
  • I still cannot build tclreadline on Mac OSX. Could someone provide a link to some nice build so that I could RTFM ???
  • Build on GNU/linux was a breeze...

2008-03-16 Will

I just managed to build tcllibreadline on Mac OS 10.4. I first did everything Mike did (note that you will need to have the proper libreadline - I had 5.2 under /usr/local/lib already but I don't think that came with the OS - and check the /usr/lib/libreadline.dylib symlink isn't incorrect). In addition I had to:

  • set the environment variable MACOSX_DEPLOYMENT_TARGET to 10.4 (I used "setenv MACOSX_DEPLOYMENT_TARGET 10.4" but I use tcsh - always forget the bash syntax).
  • link glibtool into the build directory with "ln -s /usr/bin/glibtool libtool" as the configure scripts weren't able to create their own.

ReloadableWidgets