any ideas for a shell based on Ruby?

M

Martinus

hello newsgroup,

Recently I have played with the idea of writing a shell based on ruby.
I think this would be pretty cool, consider the following syntax:

user@machine ~> ls.sort:)time).last.rm

removes the oldest file in current directory:
1. ls returns a special array of Filename objects
2. The array is sorted by the attribute :date
3. the last element is chosen from the array
4. the file removes itself

I am looking for other good ideas that justify creating such a ruby
based shell :)

Martin
 
D

David Garamond

Martinus said:
hello newsgroup,

Recently I have played with the idea of writing a shell based on ruby.
I think this would be pretty cool, consider the following syntax:

user@machine ~> ls.sort:)time).last.rm

removes the oldest file in current directory:
1. ls returns a special array of Filename objects
2. The array is sorted by the attribute :date
3. the last element is chosen from the array
4. the file removes itself

I am looking for other good ideas that justify creating such a ruby
based shell :)

Don't take this as a discouragement, but I've always had a mixed feeling
towards a Ruby shell (or Perl shell, or C# shell, etc). If we stick to
Ruby syntax strictly, it will be a more cumbersome/verbose shell than
bash/csh (e.g. we will need to quote all filenames, environment
variables will need to in a special container, etc). If we add many
magic or shortcuts (e.g. adding methods like #filesize to String or even
overriding #size), it will not be Ruby anymore. Some people have trouble
remembering Ruby and bash, and then they now have to remember _yet
another_ syntax (which is not exactly Ruby, and not quite bash either).
I think I'll pass from using such a mixture shell on a daily basis,
except when I'm bored ;-)
 
R

Robert Klemme

Martinus said:
hello newsgroup,

Recently I have played with the idea of writing a shell based on ruby.
I think this would be pretty cool, consider the following syntax:

user@machine ~> ls.sort:)time).last.rm

removes the oldest file in current directory:
1. ls returns a special array of Filename objects
2. The array is sorted by the attribute :date
3. the last element is chosen from the array
4. the file removes itself

I am looking for other good ideas that justify creating such a ruby
based shell :)

This is coming up every once in a while.

There *is* in fact already a Ruby shell: irb. Together with fileutils you
get pretty much what you want to write...

Regards

robert
 
N

nobu.nokada

Hi,

At Fri, 7 May 2004 21:53:59 +0900,
Martinus wrote in [ruby-talk:99490]:
Recently I have played with the idea of writing a shell based on ruby.
I think this would be pretty cool, consider the following syntax:

user@machine ~> ls.sort:)time).last.rm

removes the oldest file in current directory:
1. ls returns a special array of Filename objects
2. The array is sorted by the attribute :date
3. the last element is chosen from the array
4. the file removes itself

$ irb -r pathname
irb(main):001:0> def ls(*path)
irb(main):002:1> path=["*"] if path.empty?
irb(main):003:1> path.collect {|p|
irb(main):004:2* begin
irb(main):005:3* p = File.join(p,"*") if File.lstat(p).directory?
irb(main):006:3> rescue SystemCallError
irb(main):007:3> end
irb(main):008:2> Dir.glob(p)
irb(main):009:2> }.flatten.collect(&Pathname.method:)new))
irb(main):010:1> end
=> nil
irb(main):011:0> ls.sort_by{|p|p.mtime}.last
I am looking for other good ideas that justify creating such a ruby
based shell :)

Give a glance at lib/shell.

And irbsh may clue.
http://raa.ruby-lang.org/list.rhtml?name=irbsh
 
R

Ryan Paul

hello newsgroup,

Recently I have played with the idea of writing a shell based on ruby.
I think this would be pretty cool, consider the following syntax:

user@machine ~> ls.sort:)time).last.rm

removes the oldest file in current directory:
1. ls returns a special array of Filename objects
2. The array is sorted by the attribute :date
3. the last element is chosen from the array
4. the file removes itself

I am looking for other good ideas that justify creating such a ruby
based shell :)

Martin

I was thinking about a ruby os shell last night, and wondering if anybody
had tried it. I was pondering the possibility of a ruby based vfs engine.
I was also thinking about using operator overload to simplify appending
content to files, etc. I also really want to be able to natively use xpath
style operations on xml files from the command line:

ls ~/files/file.xml//somenode/somenode2[@someattr]


Your sample syntax is very appealing, btw.

--SegPhault
 
T

T. Onoma

hello newsgroup,

Recently I have played with the idea of writing a shell based on ruby.
I think this would be pretty cool, consider the following syntax:

user@machine ~> ls.sort:)time).last.rm

removes the oldest file in current directory:
1. ls returns a special array of Filename objects
2. The array is sorted by the attribute :date
3. the last element is chosen from the array
4. the file removes itself

I am looking for other good ideas that justify creating such a ruby
based shell :)

Sorry I caught this thread so late. I actually did a little work on this. You
can read about in the ROS project mailing list archives (on RubyForge).
Essentially, my thought was to traverse the file system as if it were a Ruby
Object --in fact it would be a proxy object for the filesystem. Then self
would be the current traversal object (like current directory). Files and
subdirectories would be accessor methods in that object, as would be commands
like #ls and #cd, etc. inherited from the Filesystem::Directory class.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top