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
  • 1
    If you were going to create yet another version of a command in order to mitigate incompatibilities between existing versions of the command, I'm pretty sure this would apply.
    – Celada
    Dec 1, 2014 at 8:47
  • 1
    @Celada: if it was to be their private standard, the perspective changes -- they would develop a solution to the remaining 14 standards, not another standard :)
    – Jerry Epas
    Dec 1, 2014 at 9:14
  • This might not even be possible in some cases.
    – muru
    Dec 1, 2014 at 18:37

1 Answer 1


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.
  • @mikeserv, that is my point - even something simple as finding the POSIX conforming sh is quite challenging. But getconf is specified by POSIX, though. As always, you have to decide how portable you want to be. Portable down to ancient UNIX machines? Strictly ortable to POSIX version X? Portable to relevant Linux/BSD/UNIX systems? Dec 1, 2014 at 18:28
  • 1
    @mikeserv, you don't expect a POSIX conforming getconf in the current PATH (or builtin, shell function etc.) but you expect that instead a conforming command is there. This is just an arbitrary assumption. Dec 2, 2014 at 10:41
  • Very good point. That is what I meant by (you're probably already pretty close) and that is exactly the point made in man command's Rationale when discussing the getconf script in man sh's Examples. Your answer is correct - and had my upvote yesterday - my only quibble was with which vs command - which you fixed. Thank you. The rest was just argument for arguments' sake - though, I was in part reinforcing your statement - it can be very difficult to be sure about environment without some baseline. And so I think clear dependencies are the best option in most cases.
    – mikeserv
    Dec 2, 2014 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.