Portable wrappers for GNU, BSD, etc. versions of tools

bsdgnu

Is there any script that provides a compatibility layer to a subset (a rich subset would be best of course) of BSD and GNU commands?

As an example, possible cases handled could include:

  • dd and its incompatible M vs m block size indicator
  • ping and its incompatible -w vs -W wait time option

Best Answer

No, there is not such a script.

You basically have 2 choices:

  1. Just use the subset of options POSIX specifies. Note that it can even be challenging to get the POSIX conforming shell binary in a portable way. For example, /bin/sh doesn't have to be conforming. The portable way to get a POSIX conforming shell is: PATH=$(getconf PATH) command -v sh
  2. Just install GNU versions everywhere and use those.
Related Question