molt
molt copied to clipboard
Implement "-e CMD" in moltsh
Jim Tcl has the command line option -e CMD
that prints the result of the last command in the script CMD
.
> jimsh -e 'set a $argv; lappend a baz' foo bar
foo bar baz
It makes Jim easier to use from the shell than Tcl 8.x, particularly in pipelines where you can't do echo $code | tclsh
. It would be nice to see this option in the Molt shell. In general, I think Jim Tcl is worth looking at as a source of ideas for any new Tcl implementation.
Got an opinion about .tclshrc
(or, more likely, .moltrc
, or whatever the molt-shell client picks)? I never much used it with tclsh
myself, so I haven't implemented it.
For what it's worth, I use .tclshrc
. I import Tcllib packages that are often needed in interactive use like fileutil
, define procs like bexec
, and most importantly start the tclreadline REPL. It is less important in a Tcl implementation that has a built-in Readline clone, like Jim Tcl, but I still use .jimrc
to source my jimlib.
My primary suggestion about .moltrc
is to acknowledge the XDG directories and store .moltrc
in $env(XDG_CONFIG_HOME)
(which is ~/.config/
by default) or its subdirectory and the command history in $env(XDG_DATA_HOME)
(~/.local/share/
by default) or a subdirectory rather than pollute the user's home directory with another config and history file. Modern shells like fish follow this convention.
Added #89 to cover ~/.config/molt/config.tcl
.