News for hackers. Stuff that matters.
Re:One Year of Nushell by ChrisSD on Monday August 24, 2020 @08:51PM (#24267155)
> It also turns out that getting a shell correct is a lot more experimentation and a lot less following what the textbooks say. In practice, things like ‘stdout’ and ‘stderr’ are used in a variety of ways, as are the exit codes output by programs. Our initial designs started with a stricter view of these ideas, and softened over time as we saw that the real world is a much fuzzier place than we realized.

Good point. Exit codes can be difficult. A non-zero error value may not be an error; it could indicate a type of success or be a warning or a result of a calculation or any number of things depending on the application.

Re:One Year of Nushell by wwright on Monday August 24, 2020 @10:41PM (#24267694)
At work we have a program that uses the exit code to encode three enums. Each digit of the decimal representation of the exit code corresponds to one of these enums.

It’s some of the most cursed code I’ve ever worked with.

(God bless anyone who ever used this program and got a set fault or sigint or sighup and therefore a bizarre result.)

Re:One Year of Nushell by samatman on Monday August 24, 2020 @11:57PM (#24268027)
I was horrified by your post, because I've had to deal with load-bearing exit codes.

Then, I read the part about each digit of the decimal representation.

Now I may need to lie down for a spell.

Re:One Year of Nushell by etaioinshrdlu on Monday August 24, 2020 @10:46PM (#24267714)
That is a very bad design. Especially since you have only one byte to work with.

What is the decimal range of values used?

Re:One Year of Nushell by wwright on Tuesday August 25, 2020 @07:21AM (#24270172)
I think 11 to 200, but it’s not surjective
Re:One Year of Nushell by adamch on Monday August 24, 2020 @10:43PM (#24267698)
In a redesigned shell, ideally there would be a richer way to describe the result of a program. Maybe "return an integer and consult the manual to see what it means" isn't the best way forward.

Personally, I think Result types from Rust/Haskell/Swift make a lot of sense -- a program either succeeds with some output, or fails with an explanation of why. By default, pipes stop piping if one command fails.

Re:One Year of Nushell by moonchild on Monday August 24, 2020 @10:58PM (#24267764)
> Personally, I think Result types make a lot of sense -- a program either succeeds with some output, or fails with an explanation of why

Usually, this is what happens. Usually, the error-signalling return is accompanied by a message (posted to stderr).

> By default, pipes stop piping if one command fails

  set -o pipefail
Re:One Year of Nushell by toastal on Tuesday August 25, 2020 @12:31AM (#24268134)
pipefail is not available to POSIX shells like dash
Re:One Year of Nushell by roryrjb on Tuesday August 25, 2020 @03:16AM (#24268843)
set -o pipefail is now part of POSIX[0] and I believe as soon as someone posts a patch to dash to implement it, it will get included[1].

[0]. https://www.austingroupbugs.net/view.php?id=789

[1]. https://lore.kernel.org/linux-dash/20200701015226.GA6839@gon...

Re:One Year of Nushell by toastal on Wednesday August 26, 2020 @12:44AM (#24279191)
This is great! Thanks for posting it.
Re:One Year of Nushell by karl42 on Tuesday August 25, 2020 @02:22AM (#24268579)
Plan9 returns an error string instead of an error integer with the empty string signifying success. This seems like a simple and useful improvement to me.
Re:One Year of Nushell by majkinetor on Tuesday August 25, 2020 @02:36AM (#24268653)
> In a redesigned shell, ideally there would be a richer way to describe the result of a program

And there is in PowerShell - you can return arbitrary complex object.

Re:One Year of Nushell by codetrotter on Tuesday August 25, 2020 @09:58AM (#24271403)
Do people use PowerShell for interactive use a lot?

As a Unix person my impression of PowerShell is that it’s more robust for scripting than the Unix shells, but that the Unix shells are more suitable for interactive use. And for anything of sufficient complexity and/or size I’d personally reach for either Python or I’d write a program in Rust.

I guess in the end it comes down to personal preference and what you are familiar with.

Incidentally, when I started at the university, when I was still using Windows, and PowerShell had recently come out I actually started with PowerShell and was getting comfortable with it. But we learned about Linux at the university and a friend I made at the university was showing me Linux stuff, and I started using Linux and FreeBSD instead of Windows. If it wasn’t for that then I’d probably have been a PowerShell person today.

Re:One Year of Nushell by cookiecaper on Tuesday August 25, 2020 @03:32PM (#24275106)
PowerShell is underrated, but it's its own worst enemy, stubbornly insisting on LongForm-VerbNoun syntax for all but the most common commands that anyone familiar with the shell would expect. A few UI touchups and it could go substantially further, especially as MS continues quietly gutting the NT heritage out of Win10 and integrating more and more nix-like features, including full Linux kernel emulation, all so you can run Docker without a VM! What a world.

I continue to believe that within 10 years, Microsoft will have just switched entirely to Linux+WINE under the covers. :)

Re:One Year of Nushell by vips7L on Wednesday August 26, 2020 @08:32AM (#24281794)
The long command names are really only something you use in scripts. Powershell is my main shell for both scripting and interaction and at least on my system it comes installed with tons of short aliases for common commands.

For example: Get-ChildItem was already aliased to both ls and gci on my system.

Re:One Year of Nushell by majkinetor on Wednesday August 26, 2020 @02:23PM (#24285533)
Not just on your system. Default aliases come OTB and they were only slightly changed with arise of the pwsh so not to mirror some native commands.
Re:One Year of Nushell by vips7L on Wednesday August 26, 2020 @08:37AM (#24281830)
I use powershell full time and quite honestly I think it's better than bash. The main selling point for me was that I only need to learn posh and how it works vs having to learn 20 different utilities with varying UX.

The best example of this I think is ConvertFrom-Json vs something like jq. Jq's syntax is extremely difficult to learn, but with powershell I just built upon the knowledge I already had and got to use the same commands I use everywhere else.

Re:One Year of Nushell by majkinetor on Wednesday August 26, 2020 @08:48AM (#24281917)
I use powershell interactively 24/7.

Its totally funny (and lame) that people complain about its verbosity since its not true (verbosity is optional) and that typically shows that person wasn't involved at learning it at all and thus can be ignored.

Furthermore, there is an alias naming standard in posh, besides having all linux like names, they are usually named by first letter of verb and first and second word letter of noun (Get-ChildItem => gci; Get-Service => gsv; )

Then we have a parameter aliases, just use any unique subset of the its name ( -Computer => -C or -Co or -Com ... )

You can also customize those names with proxy cmdlets.

All in all, almost 100% of the time PowerShell sentence is way shorter then equivalent bash sentence.

Re:One Year of Nushell by steveklabnik on Tuesday August 25, 2020 @11:01AM (#24272018)
I used PowerShell basically only in an interactive capacity for a few years, but have switched to nu full-time a few months back.

There's enough aliases for bashisms that honestly, the largest hurdle to switching was "rm -r -Fo" rather than "rm -rf".

Re:One Year of Nushell by franga2000 on Tuesday August 25, 2020 @02:24AM (#24268590)
> In a redesigned shell

Correct me if I'm wrong, but aren't exit codes an OS-level thing? That would be one hell of a redesign!

Not that I wouldn't absolutely love to have rich/structured return values, but that's already hard to do in a single-language system - even ignoring backwards compatibility, doing this in a traditional OS would require a level of cooperation I don't think the industry is capable of.