Picon
Gravatar

status - NEW: GTK!

This is another status report

I have made a GTK GUI for Rubyunix.

Quick FAQ

Q) Do we need a GTK GUI?
A) No
Q) Then why did you make one?
A) Because I don't know how to do very much with a command line interface
Q) Does this mean Rubyunix won't have a command line interface?
A) NO. A graphical environment shouldn't be a requirement.
Ari/thefed/fedzor/etc. is working on the command line interface.

What works

History: use up, down, pgup, and pgdown to traverse
Commands: exit,help,cat,echo,ls,pwd
Configuration: Easily edit defaults.rb to change options

What's planned for the _near_ future

Configuration: preferences window
Configuration: an alternative to GConf
Configuration: styling options
Configuration: invocation options like `rubyunix -e exec/this/script -i gtk`
Help: a set of commands which access documentation and status of
command implementations
Help: a simple manual
i18n: translations (I don't know any useful languages, but I'll make
(Continue reading)

thefed | 31 Dec 05:54
Picon

Rust: Guided Tour

So Rust is the alternative to the Rubyunix code base. Both employ the same parser (Bash.rb), although Rust is more complete and has many useful and redeeming qualities. But this isn't about competing code bases.... yet....

So lets all start off by getting a copy of the code: http://www.aribrown.com/rust.zip

So starting in the main file... rust.rb

--> rust.rb
rust.rb is the head of the shell. It starts off my loading all of the files (in a certain order, due to method dependencies). First the non-local dependencies, then the local ones. The Dir.glob() trick is very common in all of _why's code, and it loads all of the parsers located in the parser directory. For final release, I will change this so that it is ~/.parsers/ . The Rust class is the actually OOP head of the shell, as it organizes everything else to do its part. $keys is a hash that stores all of the user's captured keys. For instance, if you choose to capture ^A, you would be able to hit ^A, and then the attached proc would be called. <at> io is the InOut class, which handles all of the IO. The only reason for using that instead of HighLine is that HighLine calls a multitude of methods to getting user input, and on *nix systems, that is Readline. And in Readline, I can't twist it so that it will check for any captured keys. And besides, I stole the best of the functionality of HighLine and put it into InOut (like colored output!).

The run method loads the user's configuration file and eval's it in the context of CommandCenter. It's a pretty simple method.

The prompt method is also very straightforward. It just asks the user for input! The reason that it is 'line += ask($prompt)' is because I would like to check for backslashes and then just add the next line onto the previous one.

--> syntax/command.rb
Obsolete and unused. Don't even worry about it!

--> syntax/pipes.rb
pipes.rb is a seemingly long and complicated file, particularly since it is one method! But really, it's not that bad. It starts out by parsing the *args. That much is obvious. The rest of it is (mostly) taken from Open3.popen3(). It takes the pipe assignments from args, and then, in a new fork, reassigns the pipes and then runs the command according to the designated style, given to it by the parser. Pipes.pipe_to should be called _only_ by helpers/parser.rb::run() or run_standard(). Those methods are called by the parser.

--> syntax/paths.rb
Pretty much self evident. Just a few useful methods for finding files. Can be called by anyone.

--> helpers/array.rb
Contains one method: string(). It is called by CommandCenter when running any ruby-based code.

--> helpers/command_center.rb
command_center.rb has the methods for running any commands in the shell environment. It includes the BuiltinCommands module so that the builtin commands can be run.

--> helpers/constants.rb
Nothing much here. Just one constant used by io.rb. If there ever needs to be any constants stored, however, the should be stored here.

--> helpers/io.rb
Simple stuff here! Basic IO operations, plus some methods that should really get removed, as they are uneeded (silence, silenced? and speak).

--> helpers/parser.rb
Contains all methods that can be used as sugar for writing parsers. It needs to be advanced and made into a class!

--> helpers/rush_control.rb
rush_control.rb is an extension of CommandCenter, but it contains methods used in the config file. It is an extension of CommandCenter because I think you should be able to capture a new key and put it into effect without having to modify your config file and relaunch the shell.

--> helpers/trollop.rb
The modified trollop command parser that **can** be used by any builtin command to parse the args. See the trollop rubyforge page for examples in general usage, and then see my examples for integration.

--> commands/builtins.rb
Plain jane. Self explanatory. Take a look and you will know! It is there, because all internal commands must be registered:
register_builtin :cmd
and all replacement programs should be registered as:
register :cmd
Subtle, but please take care to note the differences! It also contains a Kernel addition that allows for inquiries into the arrays of commands.


I hope this has given you all some good insight into the Rust codebase. Really, though, it's not as complex as it seems.

_______________________________|
- Ari
I just bought another case of RockStar. Expect architectural changes.


_______________________________________________
http://rubyunix.rubyforge.org/developers.html
thefed | 29 Dec 16:14
Picon

Attachment of Rust

And, of course, 12 hours later I realize my mistake.

Voila
Attachment (rust-12-27-2007.zip): application/zip, 26 KiB
_______________________________________________
http://rubyunix.rubyforge.org/developers.html
Picon
Gravatar

version control

Distributed Version Control is all the rage these days, so I was
wondering if folks would like a Bazaar or Mercurial Repo or something
instead of our current Subversion. That's all.

Daniel Brumbaugh Keeney
_______________________________________________
http://rubyunix.rubyforge.org/developers.html

Picon
Gravatar

status as of Dec 2007

So some of you probably are wondering exactly what is the status of
the project this whole mailing list is about.
We have two working codebases, rubyunix.rb and company by me, and rust
by Ari/fedzor. They both use a variation of bash.rb for syntactical
interpretation, and otherwise are completely separate. rubyunix.rb
still lacks any input mechanism (It just has to send something to
Rubyunix.syntax.execute(script_str)) (nudge, nudge, Ari, you said
you'd do that.)

Bash.rb

Bash.rb is somewhat clever, it handling multiple pipelines per script
(;), pipelines (|), and splitting arguments at whitespace. Better yet,
it handles escaping of those special characters, quotation of special
characters and arguments ("hey you" doesn't become "hey","you"), and
can even handle escaped quotation marks. Really, when it comes to
escaping, give it your best shot. That said, that's all it does. It
doesn't understand all the pipe redirection craziness (&>), and I
haven't bother implement sending output to a file (>)

Difference between Rubyunix's bash.rb and Rust's bash.rb

Rubyunix has bash call Rubyunix.send_command
Rust has bash call Rust.send_pipe
If you want to understand how this works in Rubyunix, see
<http://rubyunix.rubyforge.org/svn/trunk/lib/rubyunix/syntax/bash.rb>
and <http://rubyunix.rubyforge.org/svn/trunk/lib/rubyunix/buffer.rb>

Command Handling (in rubyunix)

Command handling is performed by
<http://rubyunix.rubyforge.org/svn/trunk/lib/rubyunix/path_entry.rb>
and <http://rubyunix.rubyforge.org/svn/trunk/lib/rubyunix/command_handling.rb>.
Basically, there's a Array called path which holds instances of
PathEntry. A PathEntry can either be a
ruc,ruc_dir,external,external_dir,or mixed_dir. If you like, you can
call every directory a mixed_dir, it's just for speed. RUC is the name
for ruby files made just for rubyunix, it could be imagined to stand
for RubyUnix Command. They can be easily identified by their .ruc.rb
filename ending. External is an external file, not catered to
rubyunix, which could be called. If you want rubyunix to act like a
normal shell, just add /bin, /usr/bin, and ~/bin to your path.
Unfortunately, external files have no mechanism to call them right
now. ruc_dir, external_dir, and mixed_dir are just folders which
contain executable files, either rucs or externals as appropriate.

Side note

If you are looking for a somewhat different idea of what Ruby crossed
with shells might look like, try the rbsh by the fabulous Antonio
Salazar. More information can be found at
<http://blog.withoutincident.com/2007/9/17/rubyshell-0-5-objects-files-interpolation-and-aliasing>

Work

I would absolutely love to see the differences in Rust and Rubyunix
shrink into nothingness by agreeing on design decisions. That would be
made infinitely easier if the 12 other brave folks on this list would
look through and tell me my piping is ill-conceived and my
command-handling is on the right track.
I've ordered some books for proper formal grammars, so I actually
intend to replace bash.rb sooner or later... (If any of you are good
with any formal grammar, that would be fantastic. Which one I pick is
probably going to be whichever has the best book.)

Really where Rubyunix goes is up to you folks, so write commands, add
more features, plug it into a GUI, make a new syntax, whatever. Have
fun.

Daniel Brumbaugh Keeney
_______________________________________________
http://rubyunix.rubyforge.org/developers.html

thefed | 27 Dec 01:16
Picon

da tarball!

I have a feeling that I didn't attach the tarball

Attachment (rust-12-26-2007.tar): application/x-tar, 110 KiB
_______________________________________________
http://rubyunix.rubyforge.org/developers.html
Trans | 27 Dec 22:22
Picon
Gravatar

Shell Scripting with a simple Ruby variant

A bit of an aside, since the main goal of this project appears to be
the creation of a bash-centric shell written in Ruby.... It's just
that I'm more oriented toward a cross-platform scripting dialect of
Ruby to be used for the creation of build scripts, not so much bash
compatibility. Nonetheless this seems like the place to discuss such a
thing. Am I right?

Well, in hopes that it is okay... I recently I thought of a curious
notion. Might it be possible to simply transform a bash-like variation
of Ruby syntax into Ruby. Eg.

  echo rubish.rb
  cp rubish.rb ~/Files/

Would simply translate into:

  echo "rubish.rb"
  cp "rubish.rb", "~/Files/"

With the inclusion of an expanded FileUtils, this is perfectly
runnable Ruby. And its a fairly simple transformation (for the most
part). With a little more magic, such as variables starting with $,
this could be a a quite useful scripting language that is nothing more
then a variant dialect of Ruby, i.e. if you know Ruby you'd know this
too.

What do others think of such an approach?

Thanks,
T.
_______________________________________________
http://rubyunix.rubyforge.org/developers.html

thefed | 27 Dec 00:58
Picon

FIXED Rust + Bash.rb tarball

This means ALL of the commands work. Yes, even cd

What i had to do was fix  some object copying issues with the fork  
call in pipes.rb. but its all good now!

So there are now two types of commands. Commands that affect  
environment variables should be registered with:
	register_builtin :symbol
and go in /commands/builtins/


Things that go there should be commands that affect environment  
variables, or affect things that need to be persistent. In short,  
anything listed when you type 'man cd' (it gives a list of all  
builtin commands).

commands/commands/ is for all built in programs or commands that  
aren't listed in man builtins.

So.... we should all probably get writing...

-------------------------------------------------------|
~ Ari
seydar: it's like a crazy love triangle of Kernel commands and C code

_______________________________________________
http://rubyunix.rubyforge.org/developers.html

thefed | 25 Dec 05:59
Picon

Rusty Trollop

Here is my version of the parser::

Ari
-------------------------------------------|
Nietzsche is my copilot

Attachment (rusty_trollop.rb): text/x-ruby-script, 14 KiB
_______________________________________________
http://rubyunix.rubyforge.org/developers.html
thefed | 25 Dec 05:55
Picon

Rust + Bash parser = FINISHED

Guys -

I am proud to say that most everything is FINISHED

that means that you can go ahead and use it now
EVEN for all your piping needs

However, there ARE some limitations...
	• None of the builtin commands are implemented yet.
		- only cd, ls, and pwd have minimal functionality
	• History doesn't work
		- because I can't distinguish between up and down arrows

Luckily, thats about it. So if we start implementing the commands  
now, we'll be all set!

Shevy (from the IRC channel) and I are working on writing a multi- 
threaded fast ruby version of wget/axel

like a download accelerator except in ruby!

So for writing builtin commands...
I recommend installing trollop
	sudo gem install trollop

and then copying the lib file to, say, your desktop. From there, you  
can easily edit the options() method to take an extra argument, the  
array of args, and then replace all references to ARGV with that array.

Well... at least that's what I'm going to do..

I'll post my version of trollop to the list in five minutes.

http://minnie.tuhs.org/UnixTree/V7/usr/src/cmd/

is a useful site for finding the source code of all those commands.  
This will enable us to build Drop In Replacements for the originals.

Anyways..... You know the drill!
ruby rust.rb

and test away!
Attachment (rust.zip): application/zip, 18 KiB

-------------------------------------------------------|
~ Ari
seydar: it's like a crazy love triangle of Kernel commands and C code

_______________________________________________
http://rubyunix.rubyforge.org/developers.html
thefed | 19 Dec 04:57
Picon

Latest Code Base (minus (functioning) parser)

Here it is!

Attachment (rust.zip): application/zip, 18 KiB

-------------------------------------------------------|
~ Ari
seydar: it's like a crazy love triangle of Kernel commands and C code

_______________________________________________
http://rubyunix.rubyforge.org/developers.html

Gmane