logoalt Hacker News

saghm • yesterday at 4:52 PM • 2 replies • view on HN

I'd argue that short options aren't particularly more likely to be portable. Years ago I was debugging a CI issue that turned out to be caused by a script hard-coding the short option for base64 decoding, which was not compatible across the GNU and BSD versions (one of them used -d and the other used -D, I can't remember which was which, and that's basically the same issue honestly). I was trying to figure out if I needed to check MacOS versus Linux (I think I was fixing the newly-added MacOS job at the time) when I realized that they both used --decode as the long option, which meant that the long option being used originally would have prevented the issue in the first place.


Replies

reilly3000 • yesterday at 5:41 PM

That reminds me of a really horrible afternoon in pre-gpt devops when I learned to add

```bash

if [[ $OSTYPE == “darwin” ]]; then

  alias sed=gsed
fi

  ```
Assuming you have run `brew install gnutools` on your Mac that should enable local dev for scripts that run on Linux. Apple’s bsd sed fork is strange.
yjftsjthsd-h • yesterday at 7:26 PM

Not all short options are portable, but all POSIX options are short.

➕ show 1 reply