views:

75

answers:

3

I am planning to write an object-oriented shell (based on Python). I have many ideas already. But before I am going to implement it, I want to inspire me by some existing shell.

What I basically mean by object-oriented:

  • Parameters are not just an array of strings but an array of objects.
  • The return value is also an object.
  • There is not just stdin, stdout and stderr but any possible number of named streams which can be of certain types (not just a stream of bytes).

I have read that the Windows PowerShell is somewhat like that (based on .Net). Though I am searching for some existing Linux/MacOSX shells.

Of course there is also IPython but it is not really intended as a Unix shell, i.e. piping stuff around is quite complicated.

+2  A: 

Microsoft's Powershell. Installed by default on Windows 7 & Server 2008, can be installed on XP & Vista. It's a really good tool, a bit long to warm-up, but once it's done it's really usefull.

The features I really love in it is the filtering :

 ls | where-object { $_.size -eq 0 }

who can be rewritten in the compact form

 ls | ? { $_.size -eq 0 }

and the transformation (followed by it's compact form ):

 ls | foreach-object { $_.name -replace "\folderName","daba" }
 ls | % { $_.name -replace "\folderName","daba" }

you can also easily create pipe filter within the shell language, which is a pretty neat feature.

function concat()
{
    Begin { $rez = ""; }
    Process { $rez = $rez + $_ }
    End { $rez }
}


ls | % { $_.name } | concat

The last expression list all files, extract the filename and concatenate them in a single string (it might be some cmdlet to do that but I don't remember the name).

Another important part of the powershell, is the introspection, you can query your object proprety/methods from the command line :

ls | get-member

Really useful to play with new objects, it's a bit more descriptive than dir()from python

Raoul Supercopter
I don't have Windows. I am searching for some non-Windows shell.
Albert
@Albert: `ksh` at least allowed serialized objects, but I have no clue how it works exactly. It's also cited as an inspiration for the PowerShell language.
Joey
A: 

Perhaps you may want to take a look at Pash.

It is an open source implementation of the PowerShell for other platforms. For educational purposes and inspiration it might be useful. Unfortunately, as far as I can see, this promising project is not being developed.

Roman Kuzmin
There are plans to revive it within [MOSA](http://mosa-project.org/projects/mosa); they are intending for Pash to be the default shell. But that may still take a while.
Joey
A: 

According to the shell comparison list on Wikipedia, the only existing shells which can do that are MS PowerShell and IPython (if that counts as a command shell) with the IPipe extension for piping.

If you only count real cross platform solutions, MS PowerShell cannot be used. There is the Pash port of it (thanks Roman to notice it), though it is incomplete and thus not really useable.

So, to answer my question: There is no such thing yet.

Albert