Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • FreeBSD ls may not support the same long options as GNU ls, but both should understand the options prescribed by POSIX for that utility. In terms of options, POSIX says what the minimum portable subset of options should be. Commented Jan 2 at 16:50
  • 6
    Note that it's important to understand the difference between the shell (the command line interpreter), the utilities you run from the shell (e.g. cp and ls), and the operating system (kernel, like Linux or FreeBSD). The man page you link to is for the GNU coreutils implementation of ls, quite a different piece of software than Bash (even though it's also under the GNU umbrella and also has long options). Also, while the FreeBSD utilities don't have too many long options, you can install and use the GNU utilities on a FreeBSD system. Commented Jan 2 at 19:00
  • Yes and thanks @ilkkachu. I mixed up the shell and utilities. I am clear now. And thanks for confirming FreeBSD utilities does not support long options like GNU does. If I would like my script be able to run on FreeBSD also, it is better to strictly stick to the options only specified in POSIX, and also confirming them from the FreeBSD man pages. Commented Jan 2 at 23:07
  • 1
    Strange sounding take here probably, but beyond the shell syntax, POSIX compliance in your own shell scripts will often make you do more work than you actually need to and does not guarantee portability (busybox is a primary example of this). If you just care about GNU userspace and FreeBSD, just code for the subset of things both support (which is a proper superset of POSIX), possibly matching on the platform to trap out to non-portable code. You will often end up with a more concise script this way, because there’s a lot of stuff not in POSIX that most modern UNIX platforms do support. Commented Jan 3 at 2:38