BrodieRobertson/scripts

bash scripts marked as sh

LukeSmithxyz opened this issue · 1 comments

I noticed a number of these scripts are marked as #!/bin/sh, but still have some bashisms. I was running some on my system where I have sh linked to dash and had errors due to this (it would be the same on Ubuntu/Debian, where dash is default, I believe). I'd recommend running shellcheck on them all to be careful.

In general:

  • echo flags are not posix compliant, so it's best to use printf "%s" "$var" rather than echo -n "$var".
  • == is a bashism too, but it looks like a simple = would suffice in most places in these scripts.
  • [[ ]] are undefined in posix as well.

Again, shellcheck is the easiest way to know what's what. Otherwise, it's better to mark them as bash scripts.

They were intended to be be sh scripts but I must have made a few errors in some places, thanks for the heads up