Questions on CommandShell Architecture

David T. Lewis lewis at mail.msen.com
Sat Aug 20 01:21:29 UTC 2005


Hi Samir,

On Fri, Aug 19, 2005 at 10:40:01PM +0200, Samir Saidani wrote:
> Hi,
> 
> I'm currently interested by OSProcess and to avoid digging in the
> code, I would like to know a bit on the CommandShell
> architecture... Euh, first of all, David, I discovered that there is a
> little bug when I try to create the OSProcess (the unix one) plugin
> with the Squeak 3.8 (it works well with Squeak 3.7).

The only bug that I am aware of is that, in the platforms support code
maintained in Subversion, the layout of the SQFile data structure has
changed. This breaks some of the OSProcess code that uses the data
structure, such as attaching to the stdin and stdout streams. The
platforms source code is still in sort of a transitional state with
to the move to 64 bit support, so I have not put out the patch for
this in OSProcess yet. If you are seeing any other problems, please
let me know.

> Ok, I would like to know to change the stdin and stdout of
> CommandShell. In fact, I would like to use my own readCharacter and
> nextPutAll methods : how does CommandShell deal with reading and
> writing character ?

The basic idea is that the external OS "processes" are modeled
as instances of PipeJunction, which can be connected into pipelines
of programs (external OS programs or Squeak things that behave
like PipeJunctions). When a CommandShell runs a command, it assembles
the PipeJunctions into a pipeline of process proxies that represent
the external OS process commands mixed with the Squeak things,
and evaluated in such a way that the stdin and stdout of the
PipeJunctions are connected end-to-end, and the error streams are
accumulated into one stream. The end result is that stdout for the
pipeline is read from the stdout of the last PipeJunction in the
pipeline, and the stderr for all the PipeJunctions is read from
the stderr of the last PipeJunction in the pipeline.

If you create your own pipeline of PipeJunctions, you can write
to the stdin of the first "process" in the pipeline, and read the
stdout and stderr from the last "process" in the pipeline. The
SUnit tests in CommandShellTestCase contain examples that show
how to create pipelines of commands like this. 

> Moreover, David, do you know the VT102Emulator from Ian Piumarta ? I
> wonder how can we use this kind of state machine to provide for
> instance color support (and more generally, escape sequence support) ?

CommandShell does not really have any terminal emulation at all.
Ian's VT102 is a really good VT terminal emulator. In principle,
Ian's terminal emulation could be put on top of the CommandShell
interpreter, but I have not tried to do this.

Dave




More information about the Squeak-dev mailing list