Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
CommandShell
Last updated at 10:51 pm UTC on 24 November 2008
CommandShell for Squeak - Version 4.3 November 24, 2008)

Contributed by Dave Lewis (lewis@mail.msen.com)

Current version: CommandShellV4-3.sar

CommandShell is a Smalltalk simulation of a Unix command shell, with a simple dumb terminal window in Morphic and MVC. It is useful for running programs without leaving Squeak, and for piping command output directly into Squeak. Its operation is described in Overview of CommandShell.

CommandShellTranscript provides a shell window similar to the Transcript, supporting Morphic and MVC user interfaces.

ExternalCommandShell is a teletype style user interface that allows Squeak to be used directly as a Unix shell, similar to /bin/sh but with access to Smalltalk expressions and the Squeak object environment. To initiate external shell processing, evaluate ''ExternalCommandShell stop'', save the image, and restart with ''squeak -headless myImage''.

CommandShell can be loaded and run on any platform, but is most useful on Unix, Linux and Windows systems with OSProcess. On Windows, command pipelines are not yet implemented for external commands, but you can run Windows programs from the CommandShell "Squeak shell" as well as pipelines with internal shell commands. MacOS and other platforms have not been tested. On Unix, you may also wish to use DirectoryPlugin to speed up file directory access, which makes interactive commands feel much snappier in a CommandShell "Squeak shell".

When running on a Windows platform, CommandShell provides Unix style command line parsing with DOS device names (C:, D:, etc) to mimic the normal behavior of a DOS command shell. A set of builtin commands ('cd', 'pwd', 'sls' and 'edit') provide enough functionality to navigate Windows file systems, list directory contents, and edit files.

On Windows, DOS style device names (such as 'C:') are recognized as part of the path syntax, and separate current working directory paths are maintained for each DOS style device. The command '$ cd D:' is interpreted to mean 'change to the D: device and use its previous working directory path'. When running on Unix, a single current working directory path is maintained in the usual manner.

CommandShell provides a simple script processing capability. The scripting methods are contained in the 'command scripting' category of class CommandShell.

A script is a String containing a list of zero or more commands delimited by Character cr. Each command in the list is treated as as a CommandShell command line. The script commands may consist of a mix of Smalltalk expressions, shell builtins, and external commands. Simple conditional branching is supported for commands or scripts based on testing the exit status of the command lines or scripts.

Try evaluating these expressions:

Class CommandShell is a command shell, similar to /bin/sh, with a command line user interface. It collaborates with process proxies to provide command execution, and provides a limited set of built in commands similar to those in a Unix shell. Built in commands are implemented in Smalltalk. Simple Smalltalk expressions, followed by $!, are evaluated as doIt commands. All other commands are passed to process proxies to be executed externally.

CommandShell can open a terminal window in either Morphic or MVC.

Class ShellSyntax implements a simulation of Unix shell syntax, including command line parsing and file name globbing. This allows direct execution of external commands without use of an external command shell.

PipeJunction and its subclasses represent an OS process or internal Smalltalk evaluator connected in a command pipeline. PipeableOSProcess is a subclass which collaborates with instances of ExternalOSProcess, and PipeableEvaluator is a subclass to represent Smalltalk evaluation in a command pipeline.

A ProxyPipeline is a collection of PipeJunctions organized similarly to a Unix command pipeline. The elements of a ProxyPipeline are connection by pipes, such that the stdout of one proxy is connected to the stdin of the next. The proxies all share a common error (stderr) stream for their pipeline.

PipeableEvaluator evaluates Smalltalk expressions and provides a framework for pipelines of expressions combining Smalltalk expressions with external Unix commands. It behaves similarly to a ConnectedUnixProcess. Both the shell builtin commands and doIt expression commands are implemented with PipeableEvaluator. The subclass ExpressionEvaluator is used for evaluting general Smalltalk expressions as elements of a ProxyPipeline, and subclass ShellBuiltInEvaluator provides similar services for shell builtin commands.

Class ShellBuiltin provides the implementations for shell builtin commands. Instances of ShellBuiltin represent various commands, and may be installed into an instance of CommandShell with CommandShell>>installCommand:.

CrLfFileEditor is a simple editor which can be used within command pipelines. The 'edit' shell builtin creates an instance of CrLfFileEditor.

Changes in CommandShell 4.3 since CommandShell 4.2.3:


Previous versions of CommandShell:

Version 4.3 (December 31, 2007) CommandShellV4-2-3.sar

Version 4.2.2 (December 23, 2007) CommandShellV4-2-2.sar


Version 4.2.1(December 22, 2007) CommandShellV4-2-1.sar


CommandShellV3-0-5-dtl.sar+


CommandShellV3-0-3-dtl.sar


CommandShellV3-0-2.sar



CommandShellV3-0-1-dtl.sar (see SqueakMap)
The version 3.0.1 patch announcement is at: http://swiki.gsug.org:8080/sqfixes/4016.html



http://swiki.gsug.org:8080/sqfixes/2261.html



http://swiki.gsug.org:8080/sqfixes/2066.html



http://swiki.gsug.org:8080/sqfixes/1992.html

1.5.1 patch to add support for Windows: http://swiki.gsug.org:8080/sqfixes/2017.html

1.5.2 patch http://swiki.gsug.org:8080/sqfixes/2030.html to add command script support. This permits VMMaker to do a complete rebuild of your VM with one button click.









Earlier versions of CommandShell were called CommandWindow, and may be found at 1852