Well, "at least" is rather -- it would be perfect ;-) There is similar question -- Object-oriented shell for *nix . For me similarity with bash is no issue.

I would like to have some simple OOP plus LINQ. For now I am only aware of http://www.scsh.net/ but because of the syntax is a bit overkill.

Maybe I will show you by example what I mean:

run("ls ./").foreach(it => println(it.filesize))


run("find -r *.jpg") \
 .filter(it => it.datetime<today.adddays(-2)) \
 .foreach(it => run("gimp ${it.filename}"))

Is there anything closer to this "dream shell" than scsh?

Why am I asking? Because the more programs I write, the more I am drifting towards functional languages (C++ -> C#+LINQ -> Scala -?-> Clojure), and when yesterday I had to write simple find+print loop in bash it was painful. A man gets easily spoiled with all functional stuff ;-D.

  • 2
    I don't know of one, but you could probably cobble together an object-oriented shell with functional features in Python. The basics would probably take you half a day's work and about 300 lines of code, and you could expose the language to the user. Sadly, some of the syntactic elements of Python (I'm thinking of the whitespace) don't really lend themselves to this sort of thing.
    – Alexios
    Jan 30 '12 at 13:05
  • 1
    You could just use, say, Python or Ruby (your example looks Ruby-ish), for the find+print loop. (There also is rush but it seems kinda dead.)
    – sr_
    Jan 30 '12 at 13:33
  • @sr_, it was C#/Scala actually (well, kind of), thank you for the rush reference -- why didn't you post an answer instead of comment? Please do. Jan 30 '12 at 14:18

rush seems similar, e.g. allowing you to write

processes.filter(:cmdline => /mongrel_rails/).kill



but it looks rather dead. In the end, I'd go with just using some scripting language for shell tasks (instead of the other way 'round), for example as explained in "Using Python to create UNIX command line tools".

(Edit there's also a object-oriented shell in active development, albeit differing a lot from rushs concept, oh.)

Edit2 Just stumbled upon pbs, a Python wrapper making the use of Python for shell-like tasks more direct.

  • Great! I will just keep your answer as not marked for a while longer, just to draw attention to the question ;-) I don't want to close the post too prematurely, I hope you don't mind. Jan 30 '12 at 14:45
  • Sure, I'd be a little interested in more input on this issue, too. :)
    – sr_
    Jan 30 '12 at 15:00

You'd have to write your own objects for the LINQ stuff, but expanding bash to OOP is pretty easy. Check out https://github.com/uudruid74/bashTheObjects

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.