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 CommandShell.
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.
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. UnixCommandSyntax implements command line parsing and file name globbing. This allows direct execution of external commands without use of an external command shell.
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.
ShellBuiltin contains 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.