Earlier quoted context omitted.
> feels a lot more like programming When I want to program a script, I can use a scripting programming language like Python with its object oriented nature. When I want to interactively command my computer I can use a shell like bash or zsh. Do one thing and do it well.
There's an enormous grey area in-between them though, and something that bridges that area can be insanely powerful. Making it easy to go from doing something by hand to fully automating it creates value. It's one of the main strengths of a command line interface.
Four features that justify a new Unix shell
51–60 of 185 posts
Re: Four features that justify a new Unix shell
#52OSH is probably a good incremental improvement over bash, but I also enjoy using the significantly more tradition-breaking Powershell with its object oriented nature. It feels a lot more like programming and actually gives you useful suggestions right inside the terminal! On Linux the auto completion behavior is luckily less obnoxious than on Windows and it doesn't have the multi second startup delay either.
As a software developer, not a sysadmin, I have real trouble with Powershell. They didn't tradition-break enough and it's like some bastard child of .NET and Bash. I think most people have an easier time understanding https://www.cs-script.net . It's powerful but the syntax and semantics are maddening. It's going to be entrenched in the Windows world for the next 20 years and prevent anything better from coming along…
Your array logic returned just one element in this folder? Why, we’re unwrapping that!
Re: Four features that justify a new Unix shell
#53Earlier quoted context omitted.
(author here) Yeah I've been asked that before, and there are some things you can fix with a transpiler, but somethings you can't. That's why the tagline to Oil is now "our upgrade path from bash to a better language AND RUNTIME". The shell runtime needs to be fixed too, e.g. the error handling mentioned in the blog post and that I follow up on here: https://news.ycombinator.com/item?id=24872986 You might be able to…
So is the normal usage path to start using osh for interactive use and then use osh in a bash compatible mode to write scripts that are less buggy but can still be run on bash? Or is it more common to write scripts that tend to then require the osh runtime exist in whatever context they are deployed to?
Then at the top of my scripts I put this if I still want to run with bash:
shopt -s strict:all 2>/dev/null || true
Or this if I don't need to run with bash anymore: shopt --set oil:basic
Example: https://github.com/oilshell/oil/blob/master/test/spec.sh#L9docs in progress: https://www.oilshell.org/release/0.8.3/doc/oil-options.html
Having the OSH runtime exist everywhere is something we should work on: https://github.com/oilshell/oil/issues/463
Re: Four features that justify a new Unix shell
#54Two ergonomic issues in POSIX/bash not mentioned that I’d like to see a new shell improve on: - splitting pipes to separate flows (e.g one flow for stderr, one for stdout). Think of it as a graph. - native parallelization; I have to look in man every other time I use parallel.
Let's discuss on the issue if interested: https://github.com/oilshell/oil/issues/843
Oil is easy to prototype (it's just Python code), so anyone who wants to make this feature their own should feel free to dive in :)
A lot of people have ideas, which may or may not be implementable with fork(), wait(), pipe() and dup(). Anything that can be done safely with those syscalls is basically viable.
The syntax is generally the easy part compared to the runtime execution. Oil has first-class blocks already which will help a lot.
----
Related: I also want to fix redirect and here doc syntax (in a compatible way):
Re: Four features that justify a new Unix shell
#55Earlier quoted context omitted.
There's an enormous grey area in-between them though, and something that bridges that area can be insanely powerful. Making it easy to go from doing something by hand to fully automating it creates value. It's one of the main strengths of a command line interface.
I wouldn’t call it enormous — Python can be used as an interactive shell (there’s even a toy “operating system” that uses it as the only text shell), and traditional shells can write (simpler) versions of software that’s normally made in Python https://news.ycombinator.com/item?id=23643096
Re: Four features that justify a new Unix shell
#56There are some good ideas in here, but `--qsn` is described[1] like this: > Print filenames ONE PER LINE. If a name contains a newline or other special char, it's QSN-encoded like 'multi-line \n name with NUL \0 byte' This is a bad idea. There is a solution which already works. Just terminate every filename with NUL and you're done. Trying to make something "sorta kinda human readable" is a mistake when dealing with…
I also link to my Git Log in HTML post [1] from 3 years ago, which is ENTIRELY about the NUL byte solution :)
-----
Shell scripts can use both formats, but the advantage to QSN is that it preserves the line-based nature of shell.
Say I want to use wc -l, awk, or grep. Then the QSN-lines format is better than the NUL format.
Also, you can transmit a series of say SHA256 checksums in binary format with QSN-lines, or some other binary format.
Even entire JPG files, audio clips, wasm files, whatever. It's "8-bit clean" (and so are Oil strings).
Re: Four features that justify a new Unix shell
#57Just in case people are looking for something really new in a shell: besides Oil, check out fish shell. The killer feature for me is its autocompletion -- its basically psychic.
Re: Four features that justify a new Unix shell
#58These things might justify making a non-Bourne shell, but they don't justify making a greenfield shell: the fish shell already has all these features, and since we all benefit by reducing shell fragmentation, I think the author ought to work on hacking on fish more before making yet another shell.
Re: Four features that justify a new Unix shell
#59I love the direction this wants to go in. So many of these are reasons why we've banned new shell scripts on our projects and instead make python scripts.
Are there ever good reasons to choose a shell script over a Python/Ruby/etc script?
Also, I'd never prefer using the stdlib of Python/Ruby/etc for system commands like cp/chmod etc. It takes way more boilerplate code than a oneliner.
Re: Four features that justify a new Unix shell
#60Look at Oil. It tries hard to be bash compatible with optional buy-in to extension. Just use a superior language and give up on shell scripts, that's my advice.