Live data from Hacker News

PowerShell is open sourced and is available on Linux

azure.microsoft.com

271–280 of 790 posts

Re: PowerShell is open sourced and is available on Linux

#271
post #54

Earlier quoted context omitted.

Bash is 27 years old. It was written to replace the Bourne shell, which is 39 . It is not terribly surprising that a 9 year old tool like Powershell made some improvements over an earlier tool that was already old enough to vote!

I don't see a tremendous amount of accumulated wisdom in Powershell. It may be newer, but I'm not sure they looked at prior art or had design members who were shell gurus in any other shell than `cmd.exe`, which is a horrific shell. Why are commands horrendously long in powershell? If you spend time in the shell, you don't want your fingers falling off due to overuse. Aside... one of the design decisions Microsoft to…

There are lots of aliases for cmdlets for exactly this reason - interactive use. The verbose commands are useful when reading a script that isn't working at 3am in the morning when your boss is breathing down your neck to fix it "stat!".

RE - your aside '\' vs '/' - I think most of us still shake our head at that decision.

Jeffrey Snover [MSFT]

Re: PowerShell is open sourced and is available on Linux

#272
post #256
post #32

Earlier quoted context omitted.

Is this really so useful in practice? I have never used PowerShell before (nor do I have plans to do so in the near future), but I would imagine the downside is complexity, both for user and especially for developers. With text you just read and parse, while with objects you need to know the object type, its fields,... Whatever happend, I hope text stays here (and I have a bad feeling about it ever since I met system…

Could you elaborate on what the actual complexity is, rather than what you imagine? For a developer writing a tool, exposing an interface as objects is far easier than having to constantly serialize data into a string. Keep in mind that once you serialize data into a string, you can never change the order of the data or else other tools will break. Not so with a object based interface. In other system-admin type task…

What about:

    ip addr show | grep inet
Edit: wrote back original command and replied below instead

Re: PowerShell is open sourced and is available on Linux

#274

Earlier quoted context omitted.

Hey, don't forget cut and xargs!

*gulp* I've heard people say that, but I haven't delved into them!! :-S

cut doesn't match awk, but it's handy for the little stuff. And xargs is the most usefull thing ever.

Re: PowerShell is open sourced and is available on Linux

#275
post #272
post #256

Earlier quoted context omitted.

Could you elaborate on what the actual complexity is, rather than what you imagine? For a developer writing a tool, exposing an interface as objects is far easier than having to constantly serialize data into a string. Keep in mind that once you serialize data into a string, you can never change the order of the data or else other tools will break. Not so with a object based interface. In other system-admin type task…

What about: ip addr show | grep inet Edit: wrote back original command and replied below instead

That doesn't work on my CentOS box.

  [kapil@localhost ~]$ ip addr show | grep inet
      inet 127.0.0.1/8 scope host lo
      inet6 ::1/128 scope host
      inet 192.168.128.236/24 brd 192.168.128.255 scope global dynamic eth0
      inet6 fe80::215:5dff:fe80:501/64 scope link
  [kapil@localhost ~]$

Re: PowerShell is open sourced and is available on Linux

#276
post #232

Earlier quoted context omitted.

[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…

> So, yes, someone did ask for it - the IT industry. ... who couldn't use the well-known mature shell tools since they were locked into a closed platform, and Windows' cmd.exe was comparatively very weak.

Well, lots of windows admins used things like cygwin and the like to get a unix-y working environment, but PowerShell offers a much more robust set of mechanisms to manipulate the underlying Windows operating system.

Re: PowerShell is open sourced and is available on Linux

#277
post #17

Earlier quoted context omitted.

As a full-time Linux user, I have to say that bash is overrated. For instance, on Windows I could press the up arrow through my history 20x to find a group of commands I want to run, press Enter, then press DOWN for the following command, then enter, then DOWN until I run them all. In Bash, I need to press UP 20x every single time. Yes, you can customize it a lot, and you can script it but default bash isn't that spe…

Bash is awful. But so are shells in general. Even Rob Pike says as soon as your shell program gets longer than a few lines, write it in a proper language.

When my shell program gets longer than a few lines, it's time to break it into some makefile targets with intermediate files.

I have in the past written a moderate size program in Powershell (installer for a program which needed a lot of configuration for a lot of components and got installed into a lot of different environments). And while that probably wasn't the best approach in hindsight, it wasn't actually that awful an experience.

It's not a million miles off writing a moderate size JavaScript program, except that it has an actual module system.

I wish they hadn't chosen dynamic scope though, nor the silly array result squashing behaviour.

Also the IIS 7 Powershell Provider - that was bad.

(Or a proper language is good too.)

Re: PowerShell is open sourced and is available on Linux

#278
post #220

Earlier quoted context omitted.

I feel very similarly, but then I'm of the mind that if I can't apt-get it, I'm not interested, and I'll bet that "open source" doesn't mean to MS what it means to the open source world. As for the NIH syndrome, one of my favorite Paul Graham essays is still "What Languages Fix" ( http://www.paulgraham.com/fix.html ) particularly for C#: the problem that C# was invented to solve is that Microsoft doesn't control Java…

C# incidentally solved many other shortcomings with Java. The languages are getting closer to parity, but for many years C# was pretty far ahead (if you only consider language features and not tooling/ecosystem). Between reified generics, better native interop, and many functional features, C# felt and feels more concise than idiomatic Java. And I've written plenty of both. Disclaimer: MSFT employee expressing person…

In what way was C#'s tooling not better?

Re: PowerShell is open sourced and is available on Linux

#279
For Fedora 24 users:

So some reason, the rpm that Microsoft provides doesn't list all the dependencies that it actually requires. What is even worse, the compiled binaries inside, require quite outdated versions of icu & openssl that are not available in Fedora 24 any more.

What I've come up w/ to force poweshell to run:

  # dnf install icu lldb lldb-devel lttng-tools lttng-ust
To view what we're still missing:

  $ find /opt/microsoft/powershell -name \*.so -type f | xargs ldd 2>/dev/null | grep not\ found
	    libcrypto.so.1.0.0 => not found
	    libicuuc.so.50 => not found
	    libicui18n.so.50 => not found
(libcypto* is openssl-libs package, libicu* is libicu.)

Now, you need to manually download:

http://archives.fedoraproject.org/pub/archive/fedora/linux/r...

(Yes, it's Fedora 17 == 2012 (!), which is ridiculous.)

http://archives.fedoraproject.org/pub/archive/fedora/linux/r...

and extract usr/lib64/* files from both rpms to, say, /opt/tmp/lib64.

Then finally run:

  $ LD_LIBRARY_PATH=/opt/tmp/lib64 powershell
  PowerShell
  Copyright (C) 2016 Microsoft Corporation. All rights reserved.

  PS /home/hf> $PSVersionTable

  Name                           Value
  ----                           -----
  PSVersion                      6.0.0-alpha
  PSEdition                      Core
  PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
  BuildVersion                   3.0.0.0
  GitCommitId                    v6.0.0-alpha.9
  CLRVersion
  WSManStackVersion              3.0
  PSRemotingProtocolVersion      2.3
  SerializationVersion           1.1.0.1
It's a very strange feeling to see "Copyright (C) 2016 Microsoft Corporation" in xterm, if you ask me.

Re: PowerShell is open sourced and is available on Linux

#280

Powershell is the first language where I managed to save time by writing a program for a task. Needless to say, I'm thrilled at the prospect of using it on Linux. The only thing that I hope they will need to work on is startup time making sure it performs well on low-spec servers (It can be a bit slow starting cold on older laptops). ls -Recurse | ? { $_.Name -match ".+docx" }

I am not sure what your example does. How does it differ from

find . -name ".docx"

ls -Recurse | ? { $_.Name -match ".+docx" }

And, if these are the same, why type in twice as many characters as a command? Actually,

ls -R | grep "\.docx$"

is, I think, closer in spirit.

Now, the issue is things further in the pipeline, I imagine. The find solution allows selection on type name, type, date, depth, mounts, properties, file system type, ownership, relative age, inode, symbolic link. find actions include delete, exec, print, quit. This can pass on needed information to further pipeline commands.

However, an interactive shell is meant to allow expression of commands with a reasonable minimum of keyboarding (thus ls and not dir). I could argue that the "Unix" command should be

find . -n ".docx"

(because the most common -n... option used is -name).

I think, to be fully reasonable the find command you want is

find . -regex ".*\.docx$"

which is still shorter than the PS example. I am not sure that for most interactive tasks, PS is a win. It does appear to be more elegant, but only usage over time will show if it is indeed more productive. I am looking for academic productive studies to be done, now that both bash and PS are available on common platforms.

Post reply on HN