1. 29
  1.  

  2. 8

    I think something people often forget is that you need an entire ecosystem around the objects for anything based on manipulating them to make sense. PowerShell has objects for WMI and various Windows system things - on Unix, these are represented by text files… usually. Maybe they could tie it in with systemd/dbus for rich introspection/management?

    1. 9

      Shells are stuck in a local optimum. First you need to drop POSIX compatibility. NuShell accepted that downside.

      Next you need to reinvent the objects you interact with, as parent noted. If everything is a file, why handle other objects?

      Another thing is the terminal. You have to drop that off you want to show anything but monospace text, like images. The cost is that it breaks ssh, vi, and ncurses.

      1. 2

        Shells are stuck in a local optimum. First you need to drop POSIX compatibility. NuShell accepted that downside.

        Next you need to reinvent the objects you interact with, as parent noted. If everything is a file, why handle other objects?

        Another thing is the terminal. You have to drop that off you want to show anything but monospace text, like images. The cost is that it breaks ssh, vi, and ncurses.

        1. 2

          Yeah. This is why I think we really need a modernized terminal protocol, one that is a low-level interface that command-line tools can interact with, while also having modern capabilities. Unfortunately, as you suggest, it won’t get traction unless there’s a good end-to-end toolchain including vi and Emacs compatibility, ncurses support, a shell, and so on… and that’s both hard because it’s a much larger scope, and hard because it creates the temptation to do it all as a monolithic system with a lot of vertical integration.

      2. 8

        haven’t changed much since their inception

        I haven’t used NuShell, but based on this article and what I know about other shells, I think that this is hugely unfair. Maybe it seems trivial now, but even things like completion and history were big changes. Plan 9’s rc didn’t really catch on but is a nice shell with interesting features. Fish is a very different shell.

        They mention PowerShell which has been around for more than a decade, but Elvish has been around for over five years too. Half the interview feels quite a lot like Rust evangelism rather than anything else. That said, I don’t really see the benefit of building structured data into shells so I’m not really an expert to discuss nuances between the projects.

        I do appreciate the section regarding posix noncompliance, though, and I wish that arguing that one shouldn’t use fish or whatever because it’s not posix compliant was seen as the unsubstantiated argument that it is.

        1. 3

          These structures shells are, in my humble opinion, more or less useless. If your script/idea is large/complex enough that it would benefit by using nushell instead of bash/posix sh, then you may as well write it in a “real” language like python or ruby. On the other hand, for interactive usage I personally only write short snippets of sh code at a time, so I wouldn’t really benefit from using a shell with structured data.

          1. 6

            I definitely disagree here. Just from all of the cases I’ve seen in my career of the developer of shell scripts having to deal with unexpected spaces in output, or the cognitive overhead of dealing with spaces and the problems they cause. Some of it comes naturally to folks, but people rarely work in a vacuum, so someone working with your shell scripts on your team likely do have to do some extra thinking to account for spaces (or figure out where they came from when debugging).

            I had the luxury of using PowerShell at an old job, and honestly I still miss it. As an above post mentions, it’s very difficult for something like that to exist on UNIX-likes, since the real benefits of PowerShell are being able to use WMI objects. Honestly, I think nu suffers from the inability to boil the ocean in this regard.

            1. 4

              I agree with you on this, in general. However, I’ve seen people who were awk wizards and could crank out an amazing one-liner very quickly to do something super useful, but one-off. Structured data might make that kind of shell mastery a little easier to develop. Or not, I’m not sure, just thinking aloud.

              1. 2

                If your script/idea is large/complex enough that it would benefit by using nushell instead of bash/posix sh, then you may as well write it in a “real” language like python or ruby.

                ‘Interactive language, or language with good data structures?’ is a real tradeoff when you have only Posixshell and Python/Ruby to choose from. Posixshell is good for interactive usage; Python and Ruby have expressive, predictable, and easy-to-manipulate data structures, namely lists and dicts. But Nushell can make this a false tradeoff, because there is is no reason a language could not be interactive-friendly (shell-like) and use structured data. At that point ‘shell or script’ becomes a question of ‘how complex is the problem’, instead of ‘how hard does the language make it?’

                The gains lie wherever solutions are only hard to write at the command line because of Posixshell’s incidental complexity. Those solutions we could dash off at the command line if only we had a better language. Nushel wants to make that possible.

                When your shell language has both interactivity and a powerful universal data structure, you’ll be able to solve so many more things ad-hoc in your shell, without needing to bail out to a scripting language.

              2. 1

                commands like ls and ps all output this one table format.

                I don’t understand this sentence. Does nushell override the system ls by a special one that does not output plain text? Or does it convert the output of regular ls into its table format?

                Either case, it is somewhat scary to think of the consequences.

                1. 2

                  They have built in commands that override the usual ones (e.g. ls and echo), but you can still access the other ones by doing ^echo

                  When run a command in NuShell it will automatically append a pipeline to autoview which is what gets the structured data and outputs the table format.

                  If you used the other ^ls it would output as usual because autoview doesn’t know how to structure it:

                  ❯ ^ls
                  Applications			docker-data			kerl				reserva
                  Desktop				entrevistas			kubernetes			reserva_error_live_view
                  
                  1. 2

                    But then, if I run “ls | myprogram” and my program expects normal ls txt output, it will fail?

                    1. 3

                      Parsing ls output is a terrible idea anyway, but to answer your question: yes it likely would.

                    2. 1

                      How do these interact with the main use of a shell – piping data through arbitrary commands?

                      1. 4

                        You can give it a structure or just pass it as is

                        https://www.nushell.sh/blog/2019/08/23/introducing-nushell.html#working-with-the-outside-world

                        > ^ls -la | lines | skip 1 | split-column " " perms files group user size month day time name
                        ----+------------+-------+----------+----------+--------+-------+-----+-------+---------------
                         #  | perms      | files | group    | user     | size   | month | day | time  | name 
                        ----+------------+-------+----------+----------+--------+-------+-----+-------+---------------
                         0  | drwxr-xr-x | 13    | jonathan | jonathan | 4096   | Aug   | 24  | 03:24 | . 
                         1  | drwxr-xr-x | 21    | jonathan | jonathan | 4096   | Aug   | 22  | 17:00 | .. 
                         2  | drwxr-xr-x | 2     | jonathan | jonathan | 4096   | Aug   | 3   | 05:39 | assets 
                         3  | drwxr-xr-x | 2     | jonathan | jonathan | 4096   | Aug   | 21  | 19:29 | .azure 
                         4  | drwxr-xr-x | 2     | jonathan | jonathan | 4096   | Jun   | 23  | 05:09 | .cargo 
                         5  | -rw-r--r-- | 1     | jonathan | jonathan | 2963   | Aug   | 22  | 20:17 | Cargo2.toml 
                         6  | -rw-r--r-- | 1     | jonathan | jonathan | 201255 | Aug   | 24  | 03:24 | Cargo.lock 
                         7  | -rw-r--r-- | 1     | jonathan | jonathan | 3127   | Aug   | 24  | 03:24 | Cargo.toml 
                         8  | drwxr-xr-x | 2     | jonathan | jonathan | 4096   | Jun   | 17  | 15:32 | docs 
                         9  | -rw-r--r-- | 1     | jonathan | jonathan | 148    | Jun   | 17  | 15:32 | .editorconfig 
                        
                    3. 1

                      I believe that ls is a shell built-in in bash so it wouldn’t need to be overwritten. The one in nu is just a built-in with table formatted output.

                      Ignore me. ls is not a built-in:

                      https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html

                    4. 1
                      • the built-in “viewer” for text files is cool.
                      • on Windows at least, if i type “blah.pdf” and i would have expect it to open the file with the default associated app. Instead , i just get “command not found”….
                      1. 1

                        on Windows at least, if i type “blah.pdf” and i would have expect it to open the file with the default associated app. Instead , i just get “command not found”….

                        On Windows, start file.pdf. (macOS, open, X11 world, xdg-open.)