> create programs that are highly portable, able to run on any contemporary Unix system with no runtime dependencies other than the basic utilities specified by POSIX.1-2024. (Of course, your programs may have their own runtime dependencies; that’s fine. But everything in Brut adheres to the POSIX constraint.) That means you can run your program on a wide range of hosts, from a Linux virtual machine, to a BSD server, to a Mac laptop, to a tiny single-board computer
I don't believe in "just use POSIX shell" ... Here is a recent article (not from me) that makes some good points:
- alganet.dev
- news.ycombinator.com
I actually forgot about this example, and it's pretty bad:
$ sh -c "echo 'a\nb'"
a
b
$ bash -c "echo 'a\nb'" # same program has a different meaning!!
a\nb
# POSIX doesn't help you !!!
i.e. busybox ash and dash are the default /bin/sh on Alpine and Debian respectively, and they differ a lot from bash, which is the /bin/sh on other distros (I think Red Hat based systems, although I am not sure. Maybe Arch)
Also I am not sure but on OS X did /bin/sh used to be bash 3 (which has many differences from bash 4 !!), and then it changed to zsh? Or do they have a different stable /bin/sh ? I suspect the former
---
If you really want to make shell portable in shell, you will get into crazy hacks like this: modernish/modernish
> Modernish is a library for shell script programming which provides features like safer variable and command expansion, new language constructs for loop iteration, and much more.
i.e. It's not even that you can't use echo, but you have to turn shell into a different programming language. Look at modernish code -- it's a different language, that happens to run on many shells.
----
As far as Oils, I would say OSH makes a large subset of bash a reasonable portable target -- it is the most bash-compatible shell in the world: pages.oils.pub
And YSH is a different language, which is better done in native code, at the interpreter level, than in shell (as modernish does)
18 points
Mentions
> create programs that are highly portable, able to run on any contemporary Unix system with no runtime dependencies other than the basic utilities specified by POSIX.1-2024. (Of course, your programs may have their own runtime dependencies; that’s fine. But everything in Brut adheres to the POSIX constraint.) That means you can run your program on a wide range of hosts, from a Linux virtual machine, to a BSD server, to a Mac laptop, to a tiny single-board computer I don't believe in "just use POSIX shell" ... Here is a recent article (not from me) that makes some good points: - alganet.dev - news.ycombinator.com I actually forgot about this example, and it's pretty bad: $ sh -c "echo 'a\nb'" a b $ bash -c "echo 'a\nb'" # same program has a different meaning!! a\nb # POSIX doesn't help you !!! i.e. busybox ash and dash are the default /bin/sh on Alpine and Debian respectively, and they differ a lot from bash, which is the /bin/sh on other distros (I think Red Hat based systems, although I am not sure. Maybe Arch) Also I am not sure but on OS X did /bin/sh used to be bash 3 (which has many differences from bash 4 !!), and then it changed to zsh? Or do they have a different stable /bin/sh ? I suspect the former --- If you really want to make shell portable in shell, you will get into crazy hacks like this: modernish/modernish > Modernish is a library for shell script programming which provides features like safer variable and command expansion, new language constructs for loop iteration, and much more. i.e. It's not even that you can't use echo, but you have to turn shell into a different programming language. Look at modernish code -- it's a different language, that happens to run on many shells. ---- As far as Oils, I would say OSH makes a large subset of bash a reasonable portable target -- it is the most bash-compatible shell in the world: pages.oils.pub And YSH is a different language, which is better done in native code, at the interpreter level, than in shell (as modernish does)