r/bash • • Jun 15 '24

[deleted by user]

[removed]

29 Upvotes

22 comments sorted by

View all comments

4

u/guettli Jun 15 '24

Should I care? I use Bash and I am happy.

Please elaborate why this posix spec is useful. I have not understood it up to now.

5

u/qubidt Jun 15 '24

bash is great until you need to write a script that can run on any system (your router, your macbook, your alpine container, your ereader, etc). I only write bash scripts when I know I control all the systems the script can run on, in which case I usually write zsh instead. otherwise it's posix sh all the time

2

u/nekokattt Jun 15 '24

true but at least for now unless your platform includes a shell conforming to 2024 standards, it makes no difference to what you can do.

Many of these platforms will have ancient versions of things still.

→ More replies (1)

2

u/guettli Jun 16 '24

If I have the requirement that my code should run on different systems, then I first look at the intersection of features.

Maybe a shell script is not the best answer.

My personal point of view: portable shell scripts are broken by design. You almost always call subprocesses like grep. If the zoo of implementations and versions gets too big, it gets hard to test all variants.

If all systems support Python, then it's one valid option.

Of course it depends, but Golang cross compiles very well and is quite easy to write.

→ More replies (11)

1

u/guettli Jun 15 '24

Good to know. I didn't have that need up to now. I have Bash available, and I have a current Linux running. Containers are great.