Hacker News new | past | comments | ask | show | jobs | submit login
Pash: PowerShell open source reimplementation for Linux, Mac, & Solaris (sourceforge.net)
33 points by rayvega on Oct 30, 2010 | hide | past | favorite | 15 comments



I've built something along these lines, Object Shell: http://geophile.com/osh, (GPL license). Object Shell provides for piping of python objects between commands. For example,

    bash-3.2$ osh ls -f ^ select 'f: f.size > 20000' $
    ('./.DS_Store',)
    ('./.psql_history',)
    ('./backup.log',)
    ('./loljack.jpg',)
osh invokes the interpreter. ls is osh's ls command. The -f flag restricts the ls command to files. ^ is the osh pipe character, so the list of files in the current directory is piped to the next command. select filters out objects that don't pass the predicate, in this case, that file.size > 20000. $ renders output (using python's str()).

osh also does database access, e.g.

    osh sql "select * from my_table" $
and remote access. E.g., to run the same query on every node of a cluster named foobar:

    osh @foobar [ sql "select count(*) from my_table" ] $
Piping python tuples between commands and then operating on them from the command line is really handy.

Object Shell also has a python API, e.g.

    #!/usr/bin/python

    from osh.api import *

    osh(remote('foobar',
               sql("select count(*) from my_table")),
        out())


that looks really nice. Is there an interactive version, like ipython but with pipelining? Also is there any way to use pipe for pipelining rather than carat (a bit sad but Im used to reading pipe as pipe after twenty years of Unix and DOS).


No, there isn't an interactive version, but I once tried the API from inside iPython, and that worked.

Pipe is interpreted by the shell and separates the commands on either side, so I don't see how that could work. The very first version of osh actually did run separate commands, connected by a Unix pipe, but the pickling and unpickling costs were extremely high, so I opted for running the whole command in one process.


If you felt like making a full shell replacement I'd help with Python cmdlets. I have a lot of experience reimplementing shell stuff in pythonic Apis.


I'll contact you by email.


I really hope I'm wrong about this, but I think this was all but abandoned in 2008ish, and is missing a lot of what's in PS.

(check date of newest files http://sourceforge.net/projects/pash/files/)

It's really too bad, as there are some interesting tools written in Powershell-only/first mode. I was on the hunt for something like this a little while back when I had some cool VMware tools that were only in Powershell, but wanted to run them from Linux.

Would love to hear I'm wrong about this, or that there's another ps implementation for those on Linux/ Mac.

Here is a more recent thread pining for cross-platform Powershell.

http://go-mono.com/forums/#nabble-td1573385


Looks like you are right. I wish it would be possible to un-upvote a Hacker News submission.


What are the benefits of using pash(powershell) over bash?


Nothing that a decent scripting language with a REPL and some decent libs can't provide you because that is essentially what this is.

I, for one, am quite glad that my shell does not pipe objects. Text-based transports have the wonderful property that they are suspend-able (i.e. save output to a file, transfer them to another machine load them from the file; something you can't do with objects without serialization) and consistently represented on the console and for the receiving process.

Processes on my machine send and receive arbitrary byte streams. I have specialized tools for communicating with servers with specialized protocols. If you really want a shell AND a scripting language all at once, use something like IPython: http://ipython.scipy.org/moin/


There are multiple serialization options for powershell though. And since it can be made to work fairly seamlessly with other commandline tools, it isn't usually that hard in practice


A few things come to mind:

1. Syntax that doesn't suck

2. Higher-than-text-level abstraction


This is the thing that I don't really like about PowerShell. I know I can parse clear text really easily and can do it in many different ways, but I have to rely on methods that are provided in any other type of output.


You spend less time grepping for regexs, because the data is already separated from the presentations.

Or, in short

ps OUTLOOK | kill

Ie, no grepping. Yes, that's an actual posh command, as there's aliases for common unix commands.


Also, it's OO, including through pipes.


Does it implement a sucky Windows-style Console?




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: