ruby shell?

S

Simon Schuster

what about a shell based on ruby? would such a thing be
useful/powerful? (aliasing Dir[/"usr/bin/*"] to ls returns an array,
can then specify ranges, etc) rash to
replace/include bash? :) I'm pretty new to both linux and ruby, but
why or why not?
 
D

Daniel Aquino

There is ruby based shells... Look them up and think about it some more...

You'd have to write a new shell with a ruby like syntax in all reality...

What about environment variables ?

You can't just start typing executable names that are in your path
you'd have to use back ticks or something for every single command you
want to run that isn't part of ruby...

etc...
 
R

Robert Klemme

2007/8/23 said:
what about a shell based on ruby? would such a thing be
useful/powerful? (aliasing Dir[/"usr/bin/*"] to ls returns an array,
can then specify ranges, etc) rash to
replace/include bash? :) I'm pretty new to both linux and ruby, but
why or why not?

The topic comes up frequently here. You can search the archives for
more detail.
http://blade.nagaokaut.ac.jp/ruby/ruby-talk/index.shtml

Oh, and btw, there *is* a Ruby shell: IRB. :)

Kind regards

robert
 
D

Daniel Aquino

It would be cool if we could some how write a patch that would alter
bash arrays and all that stuff to make it more rubyish...

Bash is a mess!

2007/8/23 said:
what about a shell based on ruby? would such a thing be
useful/powerful? (aliasing Dir[/"usr/bin/*"] to ls returns an array,
can then specify ranges, etc) rash to
replace/include bash? :) I'm pretty new to both linux and ruby, but
why or why not?

The topic comes up frequently here. You can search the archives for
more detail.
http://blade.nagaokaut.ac.jp/ruby/ruby-talk/index.shtml

Oh, and btw, there *is* a Ruby shell: IRB. :)

Kind regards

robert
 
R

Robert Klemme

2007/8/23 said:
It would be cool if we could some how write a patch that would alter
bash arrays and all that stuff to make it more rubyish...

Bash is a mess!

Interestingly enough the cases where I really needed arrays in bash
are extremely few. Do you need it frequently? If yes, what kind of
scripts / applications do you use it for?

Kind regards

robert
 
M

M. Edward (Ed) Borasky

Daniel said:
There is ruby based shells... Look them up and think about it some more...

You'd have to write a new shell with a ruby like syntax in all reality...

What about environment variables ?

You can't just start typing executable names that are in your path
you'd have to use back ticks or something for every single command you
want to run that isn't part of ruby...

That was something that really irritated me when I migrated from "ksh"
to "ksh + (n)awk" and then to Perl. I just found actual *programming* in
"ksh" to be totally non-intuitive, and the pattern/action style of
"nawk" programming made more sense for what I was doing. Perl at least
was a real programming language. And of course Ruby is a lot more readable.
 
R

Robert Klemme

2007/8/23 said:
It's not just arrays... lots of things are a pain..

Sorry, I find that too unspecific. Bash is great for what it's
intended to do. It's not a general purpose programming environment
but rather a scripting engine for day to day admin tasks. Maybe you
used the wrong hammer for your nail? :)

Kind regards

robert
 
D

Daniel Aquino

I just found actual *programming* in "ksh" to be totally non-intuitive

Yea I don't really use shell's for programming unless its something
simple or a system script...

How do you compare ksh to bash scripting ?
 
D

Daniel Aquino

It's not a general purpose programming environment
but rather a scripting engine for day to day admin tasks.

I agree... but the programming side of it could becoming simpler...
 
R

Robert Klemme

I agree... but the programming side of it could becoming simpler...

If you only would disclose *where* exactly you see issues. It's easy to
say "XYZ is bad" but the community (and probably you as well) would
benefit more if you came up with concrete critizism.

Cheers

robert
 
E

Eric Hodel

what about a shell based on ruby? would such a thing be
useful/powerful? (aliasing Dir[/"usr/bin/*"] to ls returns an array,
can then specify ranges, etc) rash to
replace/include bash? :) I'm pretty new to both linux and ruby, but
why or why not?

require 'shell'

(No, I don't know how to use it.)
 
T

Tomas Pospisek's Mailing Lists

Sorry, I find that too unspecific. Bash is great for what it's
intended to do. It's not a general purpose programming environment
but rather a scripting engine for day to day admin tasks. Maybe you
used the wrong hammer for your nail? :)

* Quoting in shell is hell.
* "A = 11" is a syntax error. WTF!
* "A=1; echo $A". Why once A and the other time $A? To make you weep?
* "ls 2>&1". Again: why is a filedescriptor once a number only and
the other time has an ampersand in front? Such things give me nausea.
* for i in "all files that contain a star". How long do you have for that?
30min? Less? More?
* arithmetics?!?!?!
* I could go on and on

Now why would a Ruby shell be wonderful? To reply to that, we need to know
what's so nice about a shell:

* files are first class: "ls > /tmp/kak", how nice!
* pipes
* backticks: "cat `ls|grep *family*`"
* 0=true, !0=error_code
* fileglobs
* ...

How about being able to do these things with a Ruby DSL? Like:

for lines in </etc/passwd> { line.split.map ... } > /tmp/passwd.changed
h = Hash.new < `ls #{my_dir}`.special_sort | `tee /tmp/temp_copy`

That would be nice. The shell would need to be interactive and
non-interactive...
*t
 
C

Corey Jewett

How about being able to do these things with a Ruby DSL? Like:

for lines in </etc/passwd> { line.split.map ... } > /tmp/
passwd.changed
h = Hash.new < `ls #{my_dir}`.special_sort | `tee /tmp/temp_copy`

That would be nice. The shell would need to be interactive and non-
interactive...

I haven't looked at any of the projects already out there, just
piqued my interest enough to generate this:

corey@leviathan ~> irb
class File
class << self
alias :[] new
end
?> def lines &block
arr = self.readlines
arr.collect! {|line| yield line} if block_given?
arr
end
end => nil
?> module Kernel
define_method :> do |file|
?> File.open(file, 'w') <<
?> case
?> when self.class.respond_to?:)join): self.join('\n')?>
?> File["/etc/passwd"].lines {|line| line =~ /^appserver/ ? nil :
line }.compact > "/tmp/passwd.changed"
corey@leviathan ~> diff /etc/passwd /tmp/passwd.changed
27d26
< appserver:*:79:79:Application Server:/var/empty:/usr/bin/false
 
J

John Joyce

I think it is an excellent idea to have a Ruby shell!
Instead of Bash, call it Rash!
It wouldn't be easy to create the thing, considering the other *nix
shells are all pretty robust and well developed.
However, they're also pretty old and do things in ways that are not
always fun or easy. If you use bash or another shell all day every
day, then you get used to it just like C++ or Java, but that doesn't
make it better.

It's ambitious, but irb makes it seem like a darn good idea!

Imagine a new distro or two of linux: Rinux!!
An Ubuntu derivative called Rubuntu!!
with a shell named Rash!
How could you go wrong with cool names like that!?
 
P

Phlip

John said:
I think it is an excellent idea to have a Ruby shell!

Best shell I ever saw ran in the old DOS Foxbase. You enter commands in a
little floating window (in character-mode, natch), and their "glass
teletype" responses flowed in a big background window.

Someone should put that together with ncurses.
Instead of Bash, call it Rash!

Uy. I suppose it's too late for "Shellr".
 
S

Simon Schuster

"Mogok" sounds pretty cool. "The Mogok Valley in north central Burma
is the source of the majority of the world's finest rubies and
sapphires."

hmm how could we fit a recursive acronym in there. MOGOK Overthrows
Gads Of Kakistrocracies?
 
P

Pena, Botp

From: Felix Windt [mailto:[email protected]]=20
# felix@felix-laptop:~$ expr 20 + 5 - 4
# 21
#=20
# Now, I work in the shell all day long, so maybe I'm just used to those
# things, but I didn't find them any harder to learn than some=20
# of the ground rules for Ruby.

for shell gurus, it probably should not matter. But w the current IT
state, of admins beset with multitude of problems amongst a sea of
heteregeneous platforms, architecture, networks, os, applications,
languages, whatever, we need a tool that is general purpose, kind on our
brains, yet powerful to drive a small script up to the the biggest web
framework imagineable.

eg,

botp@botp-desktop:~$ expr 1+1
1+1
botp@botp-desktop:~$ expr 1+.5
1+.5
botp@botp-desktop:~$ expr 1+0.5
1+0.5

ruby on the other hand is kinder,..

botp@botp-desktop:~$ ruby -e "p 1+1"
2
botp@botp-desktop:~$ ruby -e "p 1+.5"
-e:1: no .<digit> floating literal anymore; put 0 before dot
p 1+.5
^
-e:1: syntax error, unexpected '.'
p 1+.5
^
i see. so ruby is kind to the programmer, providing much error info as
possible

botp@botp-desktop:~$ ruby -e "p 1+0.5"
1.5
botp@botp-desktop:~$ ruby -e "p 1+0.5+Math::pI"
4.64159265358979
botp@botp-desktop:~$ ruby -e "p r=3D100; c=3DMath::pI*r; area=3Dc*r; p =
area"
100
31415.9265358979
botp@botp-desktop:~$ ruby -e "r=3D100; c=3DMath::pI*r; area=3Dc*r; p =
area"
31415.9265358979
botp@botp-desktop:~$ ruby -e "p 2**999"
535754303593133660474212524530000905280702405852766803721875194185175525
562468061246599189407847929063797336458776573412593572642846157021799228
878734928740196728388741211549271053730253118557093897709107652323749179
097063369938377958277197303853145728559823884327108383021491582631219341
8602834034688

botp@botp-desktop:~$ echo hello, world | ruby -e "p
gets.chomp.capitalize"
"Hello, world"

botp@botp-desktop:~$ rails -v

ruby is kind to me, ..or maybe, i'm just getting old and lazy :(

kind regards -botp
 
Z

Zephyr Pellerin

Simon said:
"Mogok" sounds pretty cool. "The Mogok Valley in north central Burma
is the source of the majority of the world's finest rubies and
sapphires."

hmm how could we fit a recursive acronym in there. MOGOK Overthrows
Gads Of Kakistrocracies?

Its never too late for Web2.0-esque names.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,264
Messages
2,571,317
Members
48,003
Latest member
coldDuece

Latest Threads

Top