Hacker News new | past | comments | ask | show | jobs | submit login

I did find an open source implementation here:

http://pash.sourceforge.net/

Don't know if it's any good --- never tried it; it says it's about half complete, but I don't know if it's a useful half.

After looking at the docs, you could do a lot of what Powershell does with Unix shells; you'd need a different set of conventions, where instead of using unformatted text as an intermediate format you used a streamable table format with support for metadata. Then you could have commands like 'where', which would be awesome.

$ xps | xwhere user -eq dg | xsort -desc rss | xtop 10 | xecho "rss=@.rss cmdline=@.command"

...or something. sh syntax is a bit lacking; PowerShell's got lots of useful builtins, including having native support for the format so it knows how to present it to the user. An sh version would conversion routines back and forth from text.

The tricky part would be bootstrapping; getting enough functionality quickly enough that enough people would start using it to make it sustainable.

I'd still rather use this than faff around with awk, though. I've done way too much of that. And if I never have to parse the output of ls -l using cut again, I will be a happy person.




> Don't know if it's any good --- never tried it; it says it's about half complete, but I don't know if it's a useful half.

There are at least two parties working on it who have interest in certain features to be working: It's the NuGet shell within MonoDevelop, so custom PowerShell hosts need to work as well as a bunch of things needed by NuGet. Then one of the more prolific developers actually gets paid to work on Pash to support features related to PowerShell add-ins and a few others. (My own efforts so far were mostly bits and pieces, missing cmdlets (there are still a lot of those), test cases, and weird parser behaviour, mostly due to my history of golfing in PowerShell – golfed code makes for some fun tests of edge cases.)


Isn't this just complaining you want a different tool? The entire Powershell format depends on, amongst other things, the object interface being sane, existing, and usable.

The whole point of the GNU system was working around the usual "I can see it here, need this bit, and want to put it there". If you need to do something really specific a lot, you write a tool which does that.


Exactly. The Unix/Linux world has not gone the way of a Powershell type shell for the simple reason that for the uses where we want an object-oriented API, we have a plethora of scripting languages designed for that purpose, and we all have our own favourites.

When we want a text oriented API we use shell scripts. When we want an object oriented API we pick our favourite scripting language - which may very well for many of us be different for different problem domains.


Yes, precisely. The main thing would be to do is to define the stream format, and then persuade people to actually use it.

The point of the exercise is that the traditional Unix pipelinable commands have standardised on unstructured textual data. Powershell has standardised on structured tabular data, which is what lets you do the cool things.


There's also http://www.lbreyer.com/xml-coreutils.html which is interesting.

But I've never tried it; just came across it recently as a homebrew update.


> And if I never have to parse the output of ls -l using cut again, I will be a happy person.

Try stat instead, e.g.

    $ stat -c 'NAME: %n; OWNER: %U, SIZE: %s' * 
also supports --printf (see man stat).


It's not standard enough --- coreutils and OSX's work differently.


Yeah, same with the find -printf (at least macports can install coreutils and give you "gstat"). Portability is hard :-/ http://mywiki.wooledge.org/ParsingLs


Try exploiting find(1) with -printf, with formats like:

    find "$@" -printf "%TY %Tm %Td %TT %1y %4m %3n %4U:%-3G %8s  %p\t%l\n"
and flavor the output elements and format to suit. (this sorts by date well, but would do less well on file or symlink names with embedded newlines - swap \0 for \n to wrestle with those.)




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

Search: