Ruby bash replacement

Dear Rubyists, I have been inspired by the wonderful PERL shell known as
Zoidberg (https://metacpan.org/module/Zoidberg) to work on a Ruby UNIX
command shell. I do not think this has already been done yet.

I imagine the ability to use basic commands like cd, ls, echo from Ruby
and
also to use controls like >, |, etc. For sysadmins like me, I think
this
might be a very useful tool!

So I’ve started on this task twice without making much progress. My
first
approach was to try pass ruby-bits to eval and program execution to
popen.
My current thought is that it will be a lot easier to simply override
the
class Irb. I’m not sure if this is a bad idea as my code might become
tied
to a specific version of ruby/irb.

I’m wondering if anyone else has thought about this problem and cares to
give me any advice/suggestions. If anyone is interested in
collaboration,
we could use github.

Thanks!

Rohit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 1/22/12 4:27 PM, Rohit M. wrote:

Dear Rubyists, I have been inspired by the wonderful PERL shell
known as Zoidberg (https://metacpan.org/module/Zoidberg) to work on
a Ruby UNIX command shell. I do not think this has already been
done yet.

Maybe http://rush.heroku.com/ ?


All the best, Sandor Sz

Thanks Sandor! Rush is really interesting:

local_dir =
Rush::Box.new(‘localhost’)[’/Users/adam/server_logs/’].create
servers = %w(www1 www2 www3).map { |n| Rush::Box.new(n) } servers.each {
|s| s[’/var/log/nginx/access.log’].copy_to
local_dir["#{s.host}_access.log"] }

I think it is still too different than a traditional shell for me to use
on
a daily basis, but I’m going to enjoy looking at the code!

Rohit
On Sun, Jan 22, 2012 at 10:41 AM, Sandor Szcs

On Sun, Jan 22, 2012 at 9:27 AM, Rohit M. [email protected] wrote:

My current thought is that it will be a lot easier to simply override the
class Irb. I’m not sure if this is a bad idea as my code might become tied
to a specific version of ruby/irb.

Alternately, you could base it on one of the third-party IRB
replacements, like pry, ripl, dietrb, etc. (pry already has commands
like cd.)

Alternately, you could base it on one of the third-party IRB
replacements, like pry, ripl, dietrb, etc. (pry already has
commands like cd.)

Pry however does not aim to replace bash.

To work on a Ruby UNIX command shell.

I am working on something similar, but it will be a hybrid
shell. It will be somewhat similar to bash in some ways,
and somewhat similar to irb in other ways, although bash-like
syntax will have priority over ruby-like syntax.

I do not think this has already been done yet.

It always depends on how much one thinks it is finished. :slight_smile:

There was an even older version of Rush, by a guy from South Africa.

I remember there were drop-down boxes, in colours, in ruby-ncurses,
when one was typing something like “foo”.<TAB WAS PRESSED HERE, THEN THE
DROP DOWN BOX SHOWED UP>

It was quite awesome. :slight_smile:
Sadly the project died.

I imagine the ability to use basic commands like cd, ls, echo from
Ruby and also to use controls like >, |, etc. For sysadmins like
me, I think this might be a very useful tool!

Sure. I myself write ruby scripts rather than shell scripts these
days. The more ruby I can use, the better.

My first approach was to try pass ruby-bits to eval and
program execution to popen.

Eval is too annoying to use IMHO.

Sadly the ruby world has embraced it and extends it further,
with crap like class_eval or module_eval or grandma_eval.

It leads to an overcomplicated design (not always, mind you. I
am using eval myself to use a dynamic configuration object
for my projects, so that a user can extend the configuration
at runtime in any way he or she wants to.)

My current thought is that it will be a lot easier to simply
override the class Irb.

I dont know. I hate IRB. It is underdocumented and ugly.

It can only be recommended for people to instead use pry.
At least that is documented, and it has its own IRC channel
(where you can go, except when you get banned grin)

I’m not sure if this is a bad idea as my code might
become tied to a specific version of ruby/irb.

Your code will be tied to the ruby version anyway. And
IRB is just trying to eval that ruby version. But IRB
is really ugly … if you have luck extending your code
with IRB, I am curious how you did so. :slight_smile:

I’m wondering if anyone else has thought about this problem
and cares to give me any advice/suggestions.

Well, I tried so, and I am still trying to.

This is how my pseudo-shell looks right now:

http://img20.imageshack.us/img20/7564/uploadt.png

Tons of things are still missing though.

If anyone is interested in collaboration,
we could use github.

I am interested in collaboration. My profile is at
https://github.com/shevegen

My pseudo-shell is at https://github.com/shevegen/Diamond-Shell
but beware, I have not updated it for 2 months (but I
change the local code almost daily) - and it still does
not work for anyone else, only for me. I’ll fix that one
day, but it is just a hobby, so I can’t invest a lot of
time into it - individual components may be re-used by
others though perhaps, hence why collaboration may be
interesting.

Where are you? :slight_smile:

On Mon, Jan 23, 2012 at 12:27:19AM +0900, Rohit M. wrote:

My current thought is that it will be a lot easier to simply override the
class Irb. I’m not sure if this is a bad idea as my code might become tied
to a specific version of ruby/irb.

I’m wondering if anyone else has thought about this problem and cares to
give me any advice/suggestions. If anyone is interested in collaboration,
we could use github.

I’m the author of Urchin[1]. It aims to be be a Bash-like Unix shell
with great interaction with Ruby. I actually really like interactive
shells like Bash, but think that they start to suck once you need to do
something of a certain complexity. At this point I want a really easy
way to drop some Ruby in there.

Lots of the basic shell stuff works - redirection, globbing, environment
variables and job control - as well as very basic Ruby interaction.
There are a number of cool things that could be added, but I ended up
falling down a Readline rabbit hole (I spent a lot of time and effort
fixing bugs in rb-readline and am now wondering if it might be easier
and better to make the GNU Readline binding better).

Unfortunately, various real-life things have taken over of late and it
hasn’t seen any work for a few months. I do aim to get back into it
though…

I’d love to hear any more thoughts and ideas you have!

1 - https://github.com/Spakman/urchin

Marc H. wrote in post #1042090:

I do not think this has already been done yet.

It always depends on how much one thinks it is finished. :slight_smile:

There was an even older version of Rush, by a guy from South Africa.

I remember there were drop-down boxes, in colours, in ruby-ncurses,
when one was typing something like “foo”.<TAB WAS PRESSED HERE, THEN THE
DROP DOWN BOX SHOWED UP>

It was quite awesome. :slight_smile:
Sadly the project died.

Indeed, this was 2004-2005 or somewhere thereabouts? I’ve not seen Reyn
anywhere in quite some time. I wasn’t personally terribly interested in
the curses interface so I moved on to work on rs, but before I got
around to implementing a solution to the problem of natural object
streams (i.e. pipes for objects as well as text), Rubinius started
taking all my time and it got left by the wayside.

I’ve not kept tabs on the state of the art terribly well, but I think
the alternatives of Urchin, detailed by Mark earlier, and the new rush,
probably cover most of the regular use cases. There’s still – in my
opinion – demand for an object shell, but it’s not terribly pressing.

If one did want to work on a shell of their own, the ripl project would
probably be a good place to start. In addition to, that is, carefully
studying the shell-pertinent parts of the *x architecture.


rue

Maybe ‘fresh’ could help you:

https://github.com/janlelis/fresh

this is some post about it:

http://rbjl.net/43-use-fresh-ruby-as-your-shell

in the fresh’s github page, there are also mentioned another
alternatives:
https://github.com/danielb2/rubsh
https://github.com/Spakman/urchin
https://github.com/hayeah/rubish

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs