And errors out expectedly using dash or ash, very nice POSIX Sh compliant shells:

$ ./foo.sh
./foo.sh: line 5: [: bar: integer expression expected

So the lessons here are twofold:

  • Always use shellcheck to check your shell code
  • Never use Bash or rely on Bash(isms). Always prefer POSIX Sh

โค‹ Read More

Participate

Login to join in on this yarn.