1. 25
  1.  

  2. 6

    If powershell seems interesting but you’re put off it nushell is a less-mature implementation of some of the core concepts, it looks promising.

    If I remember correctly Oil shell is another attempt to make shells easier to use, it’s not as obviously inspired by powershell, but includes the ability to pass around structured data (among many other improvements).

    1. 6

      PowerShell has Shell in the name, but it’s closer to Perl and friends than Bash and friends (edit: I’m thinking of zsh or fish here). Great for scripting, but I personally cannot use it at the terminal (off the top of my head: Get- and Set- prefixes for every command render tab expansion infuriating to use, every error is a ToString()ed .NET exception prefaced with Microsoft’s classic over-explanatory text, ^D doesn’t work).

      Generally, “shell” the day-to-day human interface serves a very different purpose to “shell” the system scripting language, but everyone seems to treat them the same.

      1. 4

        The objects thing is great but only when your programs know how to deal with those objects. “Text is the universal interface”. It’s an ease-of-life solution, not a short term ease-of-use solution.

        1. 3

          Indeed. .Net + COM makes that possible on Windows. It’s not possible on Unix at this time, and frankly, even if a universal object model were to be developed it would be hailed as the coming of the Antichrist by the text faithful.

          1. 2

            GObject or DBus are the closest analogies on the Linux side. I’m no Windows dev so I can’t be sure how similar they actually are, but it seems like something like PowerShell could be implemented on one or both of them.

            And you’re right, any attempt to do something like that would result in wailing and gnashing of teeth the likes of which we have never heard before.

          2. 2
            1. In cases where it works, objects are more safe. Too many one- or few-liners that broke when on of the tools in the endless pipe chain change their output format.

            2. The objects always are pasted as plain text to STDOUT, so every tool that cannot parse these objects natively should be able to parse the resulting string.

            PowerShell is really useful hybrid of bash and Python, figuratively speaking. It’s a bit verbose for a interactive shell, but with tab completion that’s not such a big deal. And completion in ps is rock solid.

            1. 2

              PS can convert streams to CSV.

              1. 1

                It’s actually not that hard to parse the output of programs that just speak text. Think of it this way: you probably already do this today using cut or awk or something like that (at least that’s what I used to do). Instead of figuring out how to parse that output every time I enter a command, just make one wrapper that turns the output into objects with fields with names. Then, like OP said, you can interrogate it, transform it, etc., without having to remember so much (it even has tab completion in most cases, where powershell can figure out what you are doing.)

                I usually end up writing a little wrapper that does this for any text-output programs I use more than 5 times a month for this reason, and so I have tab completion of arguments and can add reasonable defaults for arguments I get sick of typing all the time.

                On the other side (pipeline stuff into a program) it already does what you would expect (just sends text to the other program) and it’s very easy to put something in a foreach to operate on each of the objects in the pipeline if you want.

                So, powershell is still pretty great even at dealing with text-output programs.

              2. 3

                PowerShell really is a great interactive shell. My favourites:

                • Readable and coherent command line parameters
                • Multiple outout formats (it’s usually really easy to output json or csv instead of plain text)

                It’s a pleasure to work with, but coming from bash and the likes, there’s a learning curve. But it’s fun once you get used to it.

                1. 1

                  I’ll give it a shot out of curiosity, but I have to say I prefer eval $(minikube docker-env) over minikube docker-env | Invoke-Expression anytime.

                  There is also another thing that bothers me. Using the same name for two different things. Using the example in the blog post unix sort vs PowerShell sort. I expect when I write sort on the command line, some consistency at least and this is to be directed by the one who had a somewhat consistent sort longer (the unix world in this case).

                  They do the same thing with wget and curl. For example wget -c in PowerShell does not work. You have to wget.exe -c to get the behavior (assuming you’ve installed wget,exe with something like Chocolatey).

                  Naming things is a hard thing in computering I guess.

                  1. 1

                    I remember when PowerShell was new and some guy at the Microsoft booth at some conference was selling it really hard. Couldn’t disagree, it had a big overlap of this article.

                    So yes, PS seems to be good. The problem is a combination of factors though (for me, highly subjective)

                    • Which version is installed? It’s not 100% random, but you can have PS x,y, or z on Windows 7, 8, 10.
                    • For me shell and terminal are 90% intertwined. Still haven’t found a windows terminal that feels right, like on Linux. it’s not only select-to-copy, it’s a lot of small things
                    • And in the end it’s Windows. I chose not to fight it and try to make development work for me on Windows.
                    1. 1

                      Piping with objects does not seem like a feature of the shell, but a feature of tools that are used to produce/consume those objects. UNIX tools could relatively easily be changed to support dumping JSON instead of text, and JSON could be used as an object serialization protocol. So, if tools would be changed, then the shell could stay unmodified.

                      But, probably some consensus (or standard) would be needed how this JSON should look like.