scripts icon indicating copy to clipboard operation
scripts copied to clipboard

bash scripts marked as sh

Open LukeSmithxyz opened this issue 6 years ago • 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.

LukeSmithxyz avatar Feb 03 '20 22:02 LukeSmithxyz

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

BrodieRobertson avatar Feb 27 '20 05:02 BrodieRobertson