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".

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:

CommandShell command: 'help'

CommandShell open

CommandShell new command: 'ps -aef | edit'

CommandShell new command: 'man ps | col -b | edit'

CommandShell command: 'ps -aef | edit'

CommandShell new command: 'ps -aef | edit'

CommandShell command: 'edit /etc/hosts'

CommandShell command: 'edit /etc/hosts; exit'

CommandShell command: 'help | edit'

CommandShell command: 'ps -aef | edit'

CommandShell command: 'Time dateAndTimeNow! | edit; exit'

CommandShell command: 'Class allSubInstances! | edit; exit'

CommandShell command: 'type type | inspect; exit'

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:

Fix improper handling of executable path resolution for executables not in current PATH list, and remove incorrect permission to execute a file in current (or Squeak default) working directory if not explicitly in the unix PATH. If an executable file is not found in the PATH, an ExpressionEvaluator is created instead of a PipeableOSProcess, such that the ExpressionEvaluator writes a suitable error message to stderr of the command shell and presents an error exit status.

Change C and D event detection to not interpret as the same thing as . There was at least one combination of VM and and image for which the latter made sense, but it breaks cut and paste in the command shell window, which is not acceptable. For platforms/images in which C gets reported as event, this will just have to be treated as a bug (see Mantis 6827).