I wrote a bash script to simplify some boring task in my codebase. As most of my coworkers are using MacOS, I aimed at POSIX complience and tried to stay away from bashisms.
When it was time to distribute it to my colleges, I found out the hard way that, POSIX or not, sed and grep do not behave the same on linux and on mac. Fair enough.
Now to my question : how can I test my script with bsd tooling on linux ?
I didn't find any BSD grep package for linux (similar to the coreutils package on MacOS / BSD). Why is that ? Do they interact too much with the BSD kernel to be ported on linux ? How can I test my script to modify it ? I really don't want to install a BSD like in VirtualBox for something so simple.
./configure && make && make install
and configure them asalternative
. I did that forsed
at least without finding it a big deal. – Philippos Oct 16 '23 at 09:54POSIXLY_CORRECT
environment variable. I'll give this a try in case I can't install those tools – RaK Oct 16 '23 at 12:36grep
; aside from a few file open modes that you don't get on Linux (but which only affect performance, not functionality, as far as I can tell), you need to port libregex, and that tends to be a bit iffy in terms of libc functionality. Nothing fundamental, but also definitely not "run./configure && make
(or, because this is BSD Makefiles,bmake -m /path/to/src/freebsd-src/share/mk
) – Marcus Müller Oct 16 '23 at 15:21grep
andgnu-sed
packages. – Sotto Voce Oct 16 '23 at 22:11$PATH
. It's more work to write and maintain, but your question and comments point in this direction. – Sotto Voce Oct 17 '23 at 22:27