Earlier quoted context omitted.
It's hard to write a portable shell script. My dotfiles need to be portable, and they involve a lot of shell. Every time I introduce a new OS, I have to make changes. Various oddities get you. These, for example, look really innocent but aren't portable: find -iname 'foo*' # [1] ... | sed -e 's/ab\+c//' # [2] ... | sed -i -e 's/abc//' # [3] tar -xf some-archive.tar.gz # [4] python -c 'anything' # [5] Things like mess…
It's a well known fact that GNU tools have plenty of extra features which you have to be careful about using if you want portibility AND that many of the legacy commercial Unix implementations have positively ancient implementations and feature sets. I wouldn't really say it is so very difficult though. Every script you write isn't going to be portable, but it's not that much of a stretch to endeavor to keep your scr…
I mostly meant that in a simple statement of:
python -c "code"
…you're probably forced to assume that it's Python 2 (or write a 2/3 code) and hope that your assumption is right. You can't run `python -V`: you're a script! The point is that it is automated, or we wouldn't be having this discussion.Of course, you can inspect the output of python -V (or just import sys and look at sys.version_info.major) and figure it out, but now you need to do that, which requires more code, more thought, testing…