rs is a project to implement a non-traditional object-oriented shell in Rub=
The three main features will be the simple power of Ruby as the shell scrip=
language, an objectlike interface to files and object piping.=20
This version has a rather more robust parser so
entering Ruby code on the command-line is more
natural. Some changes were also made to prompt
handling. For all changes, see doc/CHANGES.
Anyone who reads this entire post may award
themselves one (1) pat on the back. Sorry
about the length.
##rs on irc.freenode.net (That is hash-hash-r-s)
It is advised that developers do not install the program locally at=20
this point but rather use bin/rs directly. Users may use the provided
sudo ruby setup.rb all
=3D=3D=3D Using rs
=3D=3D=3D=3D General notes
rs uses Readline which means that you can use the arrow
keys to go up and down in history and back and forth in
the current line.
rs will load ~/.rs/rc file as Ruby code if it exists.
You can use this file to execute any code you like each
time rs starts up.
=3D=3D=3D=3D Executing Ruby code
You should be able to execute any Ruby code on the line.
The parser is reasonably robust but not nearly perfect.
An expression continuing on another line can be indicated
with \ at the end of a line.
rs> 5 + 6
rs> class Foo
..> def bar
..> puts 'Baz'
rs> a =3D [1, \
=3D=3D=3D=3D Output and environment control
You can affect the output using $config values of ruby_return,
prompt and continuation_prompt. $config (and $env) behave like
OpenStructs with the distinction that a method ending with ?
returns a boolean and one ending with ! will set the attribute
Prompts may be set as static Strings or anything that responds
rs accesses the system and internal envs through $env. Any uppercase
method name, such as $env.PATH, works on system envs. In contrast,
any lowercase such as $env.path will not access or be propagated to
the outside environment.
FSOs give a relatively object-like interface to files and paths
and incorporate several File, FileUtils, Dir etc. methods.
You could of course put the FSO in a variable to avoid the repetition--also=
you feel like metaprogramming a bit, you could put a String#method_missing =
~/.rs/rc so that you can skip the #to_fso (which will eventually go away, o=
=3D=3D=3D=3D Executing programs
FSOs containing executable files may (unsurprisingly) be executed. One thin=
know about the processing of FSOs is that currently any filename that does =
start with ./, ../, / or ~/ is considered to be 'unqualified' and must exis=
$PATH. In addition to this, unknown methods at the top-level are first trea=
as unqualified files (falling back on normal if not found). The UI provides=
special handling and will automatically run executables. Arguments may also=
There are a few exceptions. If the 'input' is an Array, it is recursively
joined with newlines. If the input is an executable FSO, it will be run=20
and the result written as a String. Thirdly, if the file TO which the input
is going is executable, it is converted to an ObjectStream instead. This
brings us to our next topic.
Executable programs (and/or static input) can be chained together to
an arbitrary degree using ObjectStreams, also known as pipes.
The result of a piping operation can be queried with #result (this is
done automatically by the UI if the value of the expression is an OS).
Alternatively, an iterator interface is exposed with #each (an other
A few modifications take place on a Ruby object being piped: Arrays are
newline-joined, #to_proc objects are #called and everything else is set
to its #to_s representation.
=3D=3D=3D Current issues and bugs
The entire project is in flux. Think of it as an exploratory programming
experiment that will stretch all the way until 0.9 at which point the
real program will be extracted from the codebase at the time.
* Generally not production-ready.
* Cannot be used as a login shell.
* Inconsistent and incomplete internal model.
* The 'lexer' for determining completeness of Ruby statements has been impr=
but is still somewhat weak.
* Tests, though relatively extensive, mainly ensure that the correct operat=
is present. Work is needed in testing for failure.