News for hackers. Stuff that matters.
Re:Bringing Bash's powerful command line editing to Microsof... by ehosca on Sunday July 01, 2012 @11:43AM (#4185059)
Do yourself a favor, learn PowerShell if you have to work on Windows. http://technet.microsoft.com/library/bb978526.aspx
Re:Bringing Bash's powerful command line editing to Microsof... by Graphon on Sunday July 01, 2012 @12:50PM (#4185285)
While powershell is a valuable and interesting option, the problem with it is that it changes the basic metaphor.

For 40 years unix shells and their descendants and derivatives including cmd.exe have used files and text streams as the metaphor for interconnecting processes. Powershell changes that, and it means the output of one command goes to the input of another command as "objects".

This can be powerful, but it is also very disorienting. Which means it can be hard to learn to do even basic things in powershell, things that would take only a pipe or two and a couple unxutls programs in cmd.exe.

In cmd.exe, easy things are easy and hard things can be really hard. In powershell, hard things are hard (as opposed to "really hard") and easy things are hard.

Re:Bringing Bash's powerful command line editing to Microsof... by gouranga on Sunday July 01, 2012 @12:57PM (#4185317)
I'm not a fan of powershell but I have to use it in my line of work.

The only thing that I find sucks is that the pipeline is slow as snails. For example, an svnadmin dump piped to a file which takes 8 mins in cmd.exe takes 14 hours in powershell...

Apart from that it's bearable!

Re:Bringing Bash's powerful command line editing to Microsof... by e40 on Sunday July 01, 2012 @05:16PM (#4186171)
The only thing that I find sucks is that the pipeline is slow as snails.

This is because CreateProcess in Windows is slow. It's the reason that run make on Cygwin on Windows for not-that-large Makefiles is really, really slow. The same Makefile on UNIX and Windows differ in startup time by a wide margin. It's really painful to type "make ..." and sit there for 30 seconds on a fast machine.

Re:Bringing Bash's powerful command line editing to Microsof... by gouranga on Sunday July 01, 2012 @05:25PM (#4186216)
CreateProcess is only being called once in this case i.e. to spawn svnadmin. The exact script does the following:

   svnadmin dump d:\repo > repo.dump
The output from svnadmin has a lot of lines. Due to the fact that PS is written on top of the CLR, it reads each line into an immutable string before writing it to a file. So for every line it has to create a new System.String object and as another poster said GC it later. Also as lines are not predictable length it has to buffer them resulting in more overhead.

Effectively where *NIX shells use a fixed size buffer for pipe operations and operate on streams, PS has to convert it to lines first before writing it out.

That doesn't work when you have approximately 25 bytes per line and a 12Gb file which is where the issue is.

Re:Bringing Bash's powerful command line editing to Microsof... by shortlived on Sunday July 01, 2012 @06:08PM (#4186316)
I can appreciate the technical explanation as a programmer, but as an end-user of PS: I don't care. It's slow.
Re:Bringing Bash's powerful command line editing to Microsof... by gouranga on Monday July 02, 2012 @03:32AM (#4187774)
For the majority of tasks it's fast enough. There are a few edge cases though.
Re:Bringing Bash's powerful command line editing to Microsof... by DeepDuh on Sunday July 01, 2012 @10:44PM (#4187042)
That's when doing it the Enterprisey way bites you in the ass..
Re:Bringing Bash's powerful command line editing to Microsof... by gouranga on Monday July 02, 2012 @03:27AM (#4187759)
I don't understand your comment. There's nothing enterprisey about it.
Re:Bringing Bash's powerful command line editing to Microsof... by DeepDuh on Monday July 02, 2012 @04:31AM (#4187935)
I mean that from Microsoft's perspective. They apparently decided to put an object around something as simple and essential to performance as a line buffer. That's when you should have hired a system programmer to do that job.

Don't get me wrong, I actually like their approach in developing an OO-shell - but if it hurts performance that much someone has taken that paradigm too far. It's the typical case of someone with a hammer (OO programmer) trying to approach everything like it were nails.

Re:Bringing Bash's powerful command line editing to Microsof... by gouranga on Monday July 02, 2012 @05:02AM (#4188026)
That's a fair evaluation and one I agree with entirely.
Re:Bringing Bash's powerful command line editing to Microsof... by pjmlp on Sunday July 01, 2012 @02:03PM (#4185569)
Really 14hours?!

Have you tried to change the way the dump is done?

Re:Bringing Bash's powerful command line editing to Microsof... by gouranga on Sunday July 01, 2012 @02:09PM (#4185586)
Well you can only pipe to file as the output is on stdout. We just ran it through cmd.exe instead. 8 mins is fine - it's a 12Gb repo.

I assume it's related to PS converting every line into a system.string.

Re:Bringing Bash's powerful command line editing to Microsof... by pjmlp on Sunday July 01, 2012 @03:23PM (#4185825)
Followed by massive GC most likely. Thanks for sharing.
Re:Bringing Bash's powerful command line editing to Microsof... by ehosca on Sunday July 01, 2012 @11:32PM (#4187179)
perhaps the real solution to the performance issue you mention is to have svnadmin actually write to a target file instead of crossing process boundaries to redirect stdout ?

have you tried :

Start-Process '{PATHTOSUBVERSION}\svnadmin' -argumentlist "dump {PATH_TO_REPOSITORY}" -RedirectStandardOutput c:\temp\repodump.dmp -Wait

more examples here : http://www.youtube.com/watch?v=9sn2L0E5jT8

Re:Bringing Bash's powerful command line editing to Microsof... by gouranga on Monday July 02, 2012 @03:12AM (#4187716)
Never tried that. I will have a go. Thanks for the suggestion.

Unfortunately its very verbose for a simple case which works fine in cmd so I'm not sure that it warrants using that tool

Re:Bringing Bash's powerful command line editing to Microsof... by jules on Sunday July 01, 2012 @05:24PM (#4186209)
I do only easy things with Powershell and I found it much nicer than classical shells. It's more consistent in the command names and parameter passing. You also need to learn far fewer commands, because Powershell follows the Unix philosophy of small tools that do one thing well much more than Bash+Unix tools. For example if you do "ls" then you get a table where one of the columns is LastWriteTime. Want to sort by that column? "ls | sort lastwritetime". This works without hassle because ls returns a list of objects, and sort sorts a list of objects by a given property, instead of serializing everything to text that would need to be parsed first. I'm sure that Unixes' ls has an option built in to ls to sort by that column, but off the top of my head I have no idea what it is, and many commands that output lists of things do not have that option.

You even get autocompletion across commands: if you type "ls | sort _" where _ is the cursor, then you get a list of properties that you can sort objects returned by ls by (LastAccessTime, LastWriteTime, Extension, etc).

Re:Bringing Bash's powerful command line editing to Microsof... by alttab on Sunday July 01, 2012 @10:52PM (#4187073)
Just one more way that ms produces developers that cant do anything on their own, or outside visual studio.

Just my experience, but most ms developers have been crippled by their tooling. Powershell is no exception.

Re:Bringing Bash's powerful command line editing to Microsof... by noveltyaccount on Monday July 02, 2012 @02:08AM (#4187574)
"Powershell makes it easier to discover commands"

"You're weak and have been crippled by your tools."

o_o You're suffering from Stockholm Syndrome. Upgrade your tools and be free from menial labor.

Re:Bringing Bash's powerful command line editing to Microsof... by alttab on Monday July 02, 2012 @09:18AM (#4188708)
I disagree. All the time spent finding and learning new tools can be spent getting things done. I use bash, vi, grep, and man and I can get 95% of what I need done with just those.
Re:Bringing Bash's powerful command line editing to Microsof... by noveltyaccount on Tuesday July 03, 2012 @11:04PM (#4197393)
Good for you. As long as we're making up numbers: I can get 100% of what I need done in 80% of the time as you, simply because I use superior tools that eliminate menial labour. Get out of your bubble.
Re:Bringing Bash's powerful command line editing to Microsof... by bobson67 on Sunday July 01, 2012 @09:37PM (#4186837)
> it means the output of one command goes to the input of another command as "objects".

Only if both commands support objects. If one of them doesn't then PowerShell just deals with text. I've sent the output of PowerShell commands to perl scripts and GNU utils without any problems. It just worked. I'm still a powershell newbie, and this has made it easy for me to learn it while still using what I know.

Re:Bringing Bash's powerful command line editing to Microsof... by slowpoke on Sunday July 01, 2012 @01:41PM (#4185490)
Do yourself a favor and don't lock yourself even more into the Windows environment if you, for whatever reason, have to work with it.
Re:Bringing Bash's powerful command line editing to Microsof... by Permit on Sunday July 01, 2012 @02:45PM (#4185718)
May I ask why?
Re:Bringing Bash's powerful command line editing to Microsof... by slowpoke on Sunday July 01, 2012 @07:50PM (#4186537)
Because lock-in is the only reason Windows is still so heavily entrenched on the market. This isn't even about the merit of Powershell as a program. This is about a tool which is designed to work on Windows (and Windows only[1]), and thus to increase the strength of the chains that bind you to the operating system.

Ever wondered why Microsoft didn't just make a bash-compatible shell? It's not like they couldn't - it's that they don't want. It would make it easier for people to jump ship, after all. And that's something they hope to prevent.

[1]: Yeah, yeah, there's a PS port to Unix land, but no sane human being will seriously use that. It's pretty much just another waste of time to save people from their mistake of investing into a proprietary tool tied to a proprietary environment.

Re:Bringing Bash's powerful command line editing to Microsof... by TheAmazingIdiot on Sunday July 01, 2012 @03:16PM (#4185802)
Many a times, Microsoft will retire the older methods for something blazing new, and ruin what application knowledge you had in the process.

These jumps in "technology" are perhaps forward, but also very much backward. I've seen it time and time again with clients who have bought a new computer and had to deal with growing pains (and hatred) of the blue globe, ribbons, and other 'we changed the gui to make it hard to do what you previously did easily'.

At least in the Linux world, your knowledge isn't decimated on an update. There may be depreciations, but those are rarer than MS "we update the world'.

Re:Bringing Bash's powerful command line editing to Microsof... by forgotusername on Sunday July 01, 2012 @04:46PM (#4186076)
My experience of Microsoft was that they're the most backward compatible source of technology around. Perhaps you could provide specific examples of breakage?

It's funny that this should come up in a thread about PowerShell, a replacement shell Microsoft released 6 years ago which still hasn't supplanted cmd.exe (which itself is based on syntax from the late 70s).

Re:Bringing Bash's powerful command line editing to Microsof... by coroxout on Monday July 02, 2012 @11:24AM (#4189231)
In 1990 I used the MS-DOS 5 Edit tool and QBasic and picked up the shortcuts Ctrl-insert and Shift-insert for copy and paste.

I'm still using them 22 years later. They still work in most Windows applications and all MS applications even though they're not listed. They could easily have taken them out since Ctrl-C and Ctrl-V have been standard in Windows for so long, but they didn't.

I also got quite comfortable with using F2 and F4 to edit my previous DOS command, which still work in Command Prompt. And since Command Prompt now has tab completion and copy and paste, I don't really feel the need to add a bash-style command history. In fact I can never remember the bash equivalent of some of the cmd history shortcuts I use.

I have, however, installed the GOW package (see bmatzelle on github) for grep, less, wc etc at the command prompt. grep is so much faster than the MS equivalent "find" it's not funny, e.g. I just searched for a 9-digit number across 13 files containing 4 million lines (158MB) and grep took 1 second; find took 57.

Re:Bringing Bash's powerful command line editing to Microsof... by JamesLeonis on Sunday July 01, 2012 @10:02PM (#4186905)
It couldn't replace the command prompt because of security issues. Basically it made it very easy for virus writers to run powerful commands that the OS would blindly run. In response, Microsoft not only made scripts not executable by default, there is also a "signing" thingamajig where a script won't be executable unless it is specifically signed off to run[1], including those written by you.

[1]: http://www.hanselman.com/blog/SigningPowerShellScripts.aspx

It also isn't a drop in replacement for the command prompt. They exist as two separate programs, instead of the Unix general Terminal and shells run inside.

In my experience, Powershell has a lot of potential but is hampered by clunky interfaces and the lack of a true robust security system across the OS. Add on top of that the large malware industry around Windows, Powershell is basically a non-starter as a replacement for the vanilla command prompt.

Re:Bringing Bash's powerful command line editing to Microsof... by Permit on Sunday July 01, 2012 @07:08PM (#4186441)
If we're speaking strictly in regards to UI, then this is not a problem unique to Windows. I mean, would you not agree that Ubuntu's implementation of Unity changed the GUI a considerable amount compared to previous versions?
Re:Bringing Bash's powerful command line editing to Microsof... by slowpoke on Sunday July 01, 2012 @07:32PM (#4186495)
The difference is that in the world of GNU/Linux, a different desktop environment or window manager is usually just a single package manager command away. You're being free to choose. Microsoft will force their UIs on you, and there's nothing you can do about it (except not updating, which is a workaround, not a solution).
Re:Bringing Bash's powerful command line editing to Microsof... by roel_v on Monday July 02, 2012 @05:12AM (#4188053)
LOL. You show me a Linux machine that runs 15-year old binaries without problems, or source code that old that compiles against a modern machine, or even just source code 2 years old, for that matter. I'm not a big Microsoft fan but saying that they're less backwards compatible than the alternatives is talk from the looney bin.

"At least in the Linux world, your knowledge isn't decimated on an update."

Of course, so that's why the time I put into learning how LILO worked is now paying off so greatly! Oh no wait it doesn't, because LILO went the way of the dodo (as far as I can tell, I don't use Linux all that often any more). Wait, all that time I used to spend on manually insmod'ing kernel modules to get my audio to work with the various audio systems, that has paid off! Hmm no, that too is a crapshoot that changes every year or so. Config file format? Different between all programs. Desktop integration? Different desktop systems, who each change how they work every 2 or 3 years. Gfx card drivers? Depends on the brand, make and (if you're lucky) distro. Networking setup? Lol, don't get me started.

Re:Bringing Bash's powerful command line editing to Microsof... by dr42 on Monday July 02, 2012 @12:21PM (#4189472)
You're only talking about all the trivial stuff, the IT setup, getting drivers to work with different hardware. This is the just the same on windows, except it has a much broader support for more hardware.

Of course things like config files change, but unix remains one of the most backwards compatible platforms to build anything on.

Re:Bringing Bash's powerful command line editing to Microsof... by roel_v on Monday July 02, 2012 @03:16PM (#4190435)
Did you only read a few words of my post? How about binary (or even source code) compatibility with everything that is not POSIX (which is most of what a modern application needs), desktop environments, the very ways that applications interact with the user? (where files and data are stored etc.) What else is there? Sure, man 3 printf may have had the same interface for 30 years, but it's disingenuous to use that to claim that it's "the most backwards compatible platforms to build anything on".

What's even more funny is that you use "Unix" instead of "Linux", implying that software written for one Unix would magically work with others (I mean, that would be case if all was backwards compatible, right?). Have you ever written software for more than one Unix, even disregarding historical versions? The most painful concoctions needed to develop for several Unixy OS's (like, say, autotools) exist for the exact reason that they're not compatible at all. While at the same time, I've written code for Win98 almost 15 years ago whose binaries still run, without as much as changing a software setting, on Windows 7 (and probably 8 although I haven't tried) today. (again, there are plenty of things to critisize Windows for, but backward compatibility is not one of them).

"Of course things like config files change"

Yeah, that's like saying "of course a 2012 BMW is different in a few minor ways from a Model T, but essentially they're just machines with engines and wheels." Eh, yeah, sure.

Re:Bringing Bash's powerful command line editing to Microsof... by soldermont001 on Sunday July 01, 2012 @08:03PM (#4186581)
Except you can't change your default shell to it, and expect your system to work. You also can't expect that it's installed by default.
Re:Bringing Bash's powerful command line editing to Microsof... by alttab on Sunday July 01, 2012 @10:49PM (#4187065)
Powershell is retarded. Microsoft uses it for their "web services" too which defeats the entire fucking point of it being a web service.
Re:Bringing Bash's powerful command line editing to Microsof... by alttab on Monday July 02, 2012 @11:57AM (#4189369)
Not sure why I'm getting hate for this. If you want to write a client for MSOffice365 you have to be on a Windows machine... and its a web-based "cloud" service. Makes no sense if you ask me.