On Wed, Feb 25, 2009 at 09:48:08PM +0000, Nicolas Cellier wrote:
Marcus Denker <denker@...> writes:
On 25.02.2009, at 22:27, Matthew Fulmer wrote:
Each command will then be a message sent to the object referenced by the variable 'shell'.
entering 'ls' will then invoke 'shell.ls'...
I would say that a command like "ls" is not a method. It's an object (instance of a sublass of "Script" or "Command").
You want, for example, inherit things like command line parsing, standard options (e.g. --help) and things liket that. A command like ls is far too complex to be just one method.
I would say ls is a message, and Shell ls answer with a LSCommand which is kindOf: Command. A Command use lazy evaluation: it does not evaluate until a end of line or pipe message triggers evaluation (i mean send the message #value).
Before being evaluated, Command behaviour can be modified by sending all sort of message, like -l --help etc... Of course, apart options which are messages sent to the command (eventually with arguments), a list of arguments can be passed to the Command itself (Command valueWithArguments: aList).
Just have to invent the syntax now...
You may be interested in ExternalCommandShell which is part of the CommandShell package (SqueakMap, SqueakSource, etc). This lets you use Squeak as a command line shell replacing /bin/sh, and uses pipes to connect Smalltalk expressions, command objects, and external OS programs. http://wiki.squeak.org/squeak/6023 http://wiki.squeak.org/squeak/2153 http://wiki.squeak.org/squeak/1914 The syntax is a mashup of Smalltalk and unix shell conventions. The pipes are OS pipes where necessary to interact with external programs, or an object that minics OS pipe behavior if the "commands" being connected are Smalltalk expressions or command objects. For example, if you enter "help | cat" at the command prompt, you will get a Smalltalk command object that evaluates "help" and writes its output to a Unix pipe connected to an OS process running the /bin/cat command, which reads the output of the "help" command, and copies it to the shell output: sqsh> help | cat cd [path] - change default directory help - help on sqsh commands history - display command history list pwd - print current working directory sls [filepatterns] - list current directory contents snapshot - save the Squeak image exit - exit shell and quit Squeak without saving image type [names...] - indicate how each name would be interpreted if used as a command simple Smalltalk expression! evaluates a simple expression as a doIt <ctl-C> to interrupt a running program <ctl-D> to end input to a running program sqsh> Dave