Earlier quoted context omitted.
So much this. What the M$ community fails to see is that text streams can be consumed by __everyone__. We've basically all accepted the fact that programs are used longer and in different ways than we'd expect. A brittle object model can only lead to vendor lock in and indigestible output.
Nothing prevents me from changing those objects into a text stream. In fact, it's infinitely easier than turning a text stream into objects.
PowerShell is open sourced and is available on Linux
451–460 of 790 posts
Re: PowerShell is open sourced and is available on Linux
#452Earlier quoted context omitted.
Okay, I've imagined it. It does seem terrible. Fortunately, that's not a world any of us live in.
Er, it's a world all of us live in. Say, for example, ‘ps’ or ‘ls -1l’. Then you end up using awk, which is rather like a half-assed version of powershell to work around shortcomings with the unix everything-is-a-string design.
Re: PowerShell is open sourced and is available on Linux
#453Earlier quoted context omitted.
> This is why I find PowerShell to be an answer to a question nobody asked. If bash/zsh isn't cutting it for you, drop into something like Python, Ruby or Perl to do the heavy lifting. How are Python/Ruby/Perl going to give you structured objects from "ps"? That's the promise of object-based pipes. You can get useful records out of your command-line tools without having to write an ad-hoc regex.
I find that to be the issue. You are considering it just RAW text when it is actually formatted text that has been parsable for years with common unix command line tools. It not being in the format you consider a structured object does not mean it's not a object or even parsable. If you are using ad hoc regex I suspect you are not using all the tools available to you. I feel like Kernighan and Pike do a much better j…
Parsing command output with sed/awk/etc (ie. "common unix command line tools") is absolutely an ad hoc parser.
Let me give you an example that I recently ran into.
I have a tool that parses the output of "readelf -sW", which dumps symbols and their sizes. The output normally looks like this:
885: 000000000043f0a0 249 FUNC WEAK DEFAULT 13 _ZNSt6vectorIPN3re23DFA5StateESaIS3_EE19_M_emplace_back_auxIJRKS3_EEEvDpOT_
886: 000000000041c380 64 FUNC GLOBAL DEFAULT 13 _dwarf_get_return_address_reg
887: 0000000000424e60 122 FUNC GLOBAL DEFAULT 13 _dwarf_decode_s_leb128
888: 000000000043dca0 157 FUNC GLOBAL DEFAULT 13 _ZN3re23DFA10StateSaverC2EPS0_PNS0_5StateE
So I wrote a regex to parse this. Seems pretty straightforward, right?But then I noticed a bug where some symbols were not showing up. And it turns out those symbols look like this:
5898: 00000000001a4d80 0x801058 OBJECT GLOBAL DEFAULT 33 _ZN8tcmalloc6Static9pageheap_E
Notice the difference? Because it's a large symbol, readelf decided to print it starting with "0x" and in hex instead of decimal. I had to update my regex to accommodate this.That is what makes a parser "ad hoc". You write a parser based on the examples you have seen, but other examples might break your parser. Parsing text robustly is non-trivial.
Worse, it is an unnecessary cognitive burden. Readelf already had this data in a structured format, why does it have to go to text and back? Why do I have to spend mental cycles figuring out which "common unix command-line tools" (and what options) can parse it back into a data structure?
Re: PowerShell is open sourced and is available on Linux
#454Earlier quoted context omitted.
This is why I find PowerShell to be an answer to a question nobody asked. If bash/zsh isn't cutting it for you, drop into something like Python, Ruby or Perl to do the heavy lifting. PowerShell will never accumulate a library as comprehensive as what any of those three have, each has had decades to accumulate packages of all kinds, and more are still being added. It's odd, but not surprising given their history of "N…
[Disclaimer: I work for Microsoft.] As far as I recall, the original impetus behind what became PowerShell (as handed down to us in a conference room by Ballmer himself, sometime around 2001) was to fill the gap between ops people who did enterprise administration manually with tools like MMC and engineers who automated enterprise administration with tools like C++/DCOM. The latter were necessary in a lot of cases, b…
Re: PowerShell is open sourced and is available on Linux
#455Earlier quoted context omitted.
Pretty sure the section in the `ps` man page called OBSOLETE SORT KEYS indicates that even the `ps` on very old redhat machines could do this out of box... see the field `start_time`. Failing that, consider the `etimes` field (seconds since process was started) used in conjunction with the -o feature (control output format) so you can put `etimes` up front then simple pipe the output to `sort`. Those things being sai…
Honestly it was a quick and dirty one-time project, and I just needed to cobble something together. I was more just commenting on the fact that with a "strongly-typed" shell some of this stuff becomes much easier without every single tool needing to add all these options. It gets much more "Unix Philosophy" when every command doesn't need it's own sorting logic, and doesn't need it's own date display logic, and doesn…
But let's not throw out the baby with the bathwater... The unix shell ecosystem is powerful magic. There are LOTS of things that can be done there with great ease.
Not to mention--and I understand full well that this stance is falling out of fashion--MICROSOFT ... KILLED... my PAPPY! :|
Re: PowerShell is open sourced and is available on Linux
#456Earlier quoted context omitted.
I'm not a huge fan of PowerShell but you're not really making a good comparison here. Bash is "just a shell" that executes commands with a few bits of syntactic sugar here and there to make it easier to string those commands together and perform some primitive logic. PowerShell is basically an interpreter that works more like a Java Virtual Machine. Consider the hypothetical example that you need to lookup 100 users…
So I wonder how it compares to having the python interpreter open. According to my machine, running the python interpreter results in 1 PID, 129M virt, 4.6M res.
Jython is probably the more apt comparison, vs the compiled interpreter. But, it falls into the same trap as powershell: You couldn't invoke jython in a loop like you would 'python' or 'perl'.
Re: PowerShell is open sourced and is available on Linux
#457Earlier quoted context omitted.
Okay, I've imagined it. It does seem terrible. Fortunately, that's not a world any of us live in.
OK, but now imagine it's not a database, because there are programs that do act this way.
Re: PowerShell is open sourced and is available on Linux
#458`cat youCantBeWorseThanCmdRight.utf8.txt > openMeAfter.txt` in PowerShell and cmd, and tell me how good posh is now go tail a 1GB file in posh and bash and tell us your results
Get-Content -Tail some1gbfile.txt
works quite well, by the way.Re: PowerShell is open sourced and is available on Linux
#459Earlier quoted context omitted.
Java seemed to have a lot more options for deployments and monitoring for a long time. More advanced 3rd party libraries in general. It had simply been around longer and thus had those tools available. Now that C# has been standard for a while almost all of those tools have a C# equivalent. As a .NET dev I'd actually argue that the things available to C# now are actually better (especially Visual Studio), but that's…
> ...things available to C# now are actually better (especially Visual Studio), but that's certainly biased. You call Visual Studio good? Have you actually used it? VS2015 is painfully slow, and yes, I've installed all of the updates and I have no plugins or such. Heck, even Eclipse feels zippy compared to it. Something as simple as finding next text search match takes about a second. Changing to a different source c…
Eclipse can run better on a potato but it's also very simplistic. You should also be able to turn off most of the features you don't want in VS.
Re: PowerShell is open sourced and is available on Linux
#460Earlier quoted context omitted.
You can use control-O for that, which does "execute this command as if I pressed enter, then when it's done bring up the following command in command line prompt". So if you have a set of commands to run that are 20 lines up in history, you can first find them (with 20x UP or by reverse-search), then just control-O control-O control-O control-O ... to execute them one after another.
Oh. My. God. Life changing! Out of curiosity, how did you discover that you could do this?