For many years I have been using a snippet that worked well
for all purposes I tried:
But today I realized it does not play well with
/, i.e. if the
script is placed in
BINDIR will contain current
directory (whatever it is) instead of
TL;DR; the answer is
busybox sh (1.26.2),
loksh (OpenBSD 6.1 ksh),
(R55), as well as
/bin/sh from NetBSD 7.0.1_PATCH.
If you want to learn more read on.
In order to play with it properly, I wrote a test script:
Let it be in public domain.