How can I determine if a script is BSD-compatible?
*BSDThis forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How can I determine if a script is BSD-compatible?
Short of tediously cross-referencing man pages, is there a way to determine whether a script contains commands/options that either do not exist or behave differently on BSD systems? (Compared to a GNU/Linux system the script was originally intended for.)
For example, neither OpenBSD find nor FreeBSD find has a printf option. Or for OpenBSD rmdir there is no verbose option (to list removed directories), whilst FreeBSD rmdir has only the shorthand -v, so if a script contains --verbose it must be changed.
My threads always seem to attract responders who clearly haven't read what I actually wrote. It is very frustrating.
-
I expect I will end up having to write something which parses the documentation and/or sourcecode for POSIX/GNU/Busybox/OpenBSD/FreeBSD userland tools to extract a list of commands and supported arguments for each, restructure to a suitable format, then learn enough Haskell to patch ShellCheck with an extra parameter and rule(s) and whatever else is needed.
If I'm lucky maybe someone else will have done that before it next becomes relevant, but I'm not holding my breath.
My threads always seem to attract responders who clearly haven't read what I actually wrote. It is very frustrating.
I totally agree with you, that is annoying. From the other hand I don't think that tool is available, at least I have never heard anything similar. If you want to use it on different hosts you need to make it portable, or you need to make it manage all the differences. At least that's what I made. At the end you will get the answer "if you want the script to be portable, avoid all bash specific items and stick to POSIX."
Or another way to use a common language, which works identically everywhere (perl, python, ...).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.