2 ms·
bash isn't compatible with python either, unless you use #!/usr/bin/python or the like. All my shell scripts start with #!/bin/sh, so the language my user shel
by samatman 5y ago
bash isn't compatible with python either, unless you use #!/usr/bin/python or the like.
All my shell scripts start with #!/bin/sh, so the language my user shell runs is irrelevant. Sometimes I do have to preface copypasta with "bash" and end it with "exit", but it ain't the end of the world.
There are a bunch of good reasons to prefer one shell over another, this isn't one of them.
- dngray 5y agoIndeed, just use the shebang #!/bin/sh (if it's posix sh), and #!/bin/bash if you must use bash functionality. There is no reason to not use a different interactive shell.
- adrusi 5y agoPlease use #!/usr/bin/env bash if you're using bash. It seems more common to have env in /usr/bin than it is to have bash in /bin. On BSD systems, bash is often in /usr/local/bin, and on macOS the user often has a more modern bash in /opt/homebrew/bin or other package manager directory.
- Ensorceled 5y ago> bash isn't compatible with python either, unless you use #!/usr/bin/python or the like. You're rather aggressively missing the point. If you need to write and maintain bash scripts but use fish as your command line, you now need to know the idiosyncrasies of both shells ...
- adrusi 5y agoIf you want to write portable scripts and use a reasonable interactive shell, you need to know two shells anyway. Scripts should ideally be written to only use shell features defined in POSIX, since bash isn't available on every system. It's available pretty widely, but not on e.g. Alpine Linux by default, and the version on macOS is so ancient it doesn't have features like wait -n. Unless you're going to use rlwrap /bin/dash as your default interactive shell (please don't) you need to know both your interactive shell and standard shell if you're going to write portable scripts.
- Ensorceled 5y ago> Scripts should ideally be written to only use shell features defined in POSIX, since bash isn't available on every system. I don't write system scripts that need to run on systems without bash and have not needed to do that for a long, long time.