3 ms·
The correct solution here is to pick one of the following options: 1) Write a bash script and put /bin/bash in your shebang 2) Write a POSIX shell script and
by cmsj 2y ago
The correct solution here is to pick one of the following options:
1) Write a bash script and put /bin/bash in your shebang
2) Write a POSIX shell script and integrate checkbashisms into your editor.
Neither is more correct than the other.
- chasil 2y ago3) #!/bin/dash
- flir 2y ago#!/usr/bin/env dash I mean, if we're targeting portability...
- dredmorbius 2y agoI believe many Linuxes still symlink /bin/sh -> /bin/bash, so the shebang itself won't save you. Debian's assignment of /bin/dash as the default /bin/sh is relatively recent (at least for those who've been running Debian since the 1990s). I virtually exclusively write Bash scripts for my own use. I've been bit by bashisms however, and at the very least don't casually dismiss the concerns which are voiced against doing this. I'm also daily using systems which don't have a full Bash, and which really don't have the resources to run it (mostly storage, though other factors may be involved).
- yjftsjthsd-h 2y ago> Write a POSIX shell script and integrate checkbashisms into your editor. Suggestion: Use shellcheck. It will complain about bashisms if your script says #!/bin/sh and will also catch loads of other problems.