sources for e1e0 website
git clone https://git.e1e0.net/e1e0.net.git
Log | Files | Refs

20190414-1728_entry.txt (2434B)

      1 ------------------------------------------------------------------------
      2   14-Apr-2019, 17:28 (UTC)
      3 ------------------------------------------------------------------------
      5 This is a small rant about the different implementations of the most
      6 common shell tools I use everyday at work and on my free time. So sorry
      7 if you're reading this. You may be better spending your time somewhere
      8 else...
     10 My main workstation is OpenBSD. I used some linux flavours in the past
     11 (mostly debian and arch), but I have to admit I'm a *BSD fanboy.
     13 I have a laptop I barely use given to me by my current employer, a
     14 MacBook Air. I only use it occasionally at home, and of course when I
     15 have to travel for work. It serves me well, as it's small and light,
     16 although I would prefer to stay away from MacOSX ...
     18 And then there are all servers and containers at work. They are almost
     19 100% Debian.
     21 I got used to differences on the BSD vs GNU implementations of some
     22 tools, and I've been trying to stick to POSIX when writing scripts for
     23 my own sanity.
     25 Long time ago I stopped fightint the `date` command for instance and
     26 their plethora of ways of specifying the timezone (POSIX says `-u` for
     27 UTC and define `TZ` for the rest).
     29 That's only an example, then there are more complicated tools like
     30 `sed`. You can be in a lot of pain if you rely on any of the
     31 implementations and try to run your script on 2 different OSs. `POSIX
     32 sed` is quite basic, and lacks some features you may expect to be there.
     34 One of those features is in-place editing. And you may think, "hey,
     35 almost all implementations know about in-place editing, use `-i` man !".
     36 Well, as usual, devil is in the detail. Although that is (almost) true,
     37 the way it's implemented differs in ways that may give you one or two
     38 headaches. `GNU sed` uses simply `-i` with an optional extension for
     39 backup, OpenBSD does the same, but if you do not want to create a
     40 backup, you have to provide an empty string and it has to be in the form
     41 `-i''` (note, not space), the MacOS implementation (taken from FreeBSD)
     42 does mostly the same as the OpenBSD one BUT you need a space between the
     43 `i` and the empty string ... you get the idea ...
     45 So, stick to [POSIX][1], even if  you think you'll never use that script
     46 on any other machine/OS.
     48 You're welcome.
     50 [1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html
     52 ------------------------------------------------------------------------