back

by jasonpeacock·5y ago·view on hn ↗
My point is that Bash is already installed almost everywhere, including across WSL, Linux, and OSX.

Yes, when working with sub-processes you need to account for platform differences...which is also true when Python.

A Bash script "just works", while I have to direct customers to install the appropriate version of Python (or whatever else).

2 comments
> Yes, when working with sub-processes you need to account for platform differences...which is also true when Python.

The cases in which you even need to use subprocesses is much smaller with Python, because the stdlib replaces a huge amount of external programs typically used with Bash (cat, grep, awk, sed, cut, paste, wc, ls, find, etc.). And so if you stick with stdlib without subprocesses, you don't need to account for platform differences. Python has already done that work for you.

In simple cases, or cases where portability doesn't really matter, then I agree with you. But once you start caring about portability, you have to be careful to consider the compatibility differences of external programs across distributions and OSs on which Bash runs, which vary dramatically among even the simplest or most common of programs such as "ls" or "grep".

Example:

    # ubuntu 20.04
    echo fooboo | grep -Eo '.+?oo'
    > fooboo

    # macos big sur
    echo fooboo | grep -Eo '.+?oo'
    > foo
    > boo
Bash scripts being portable has little to do with Bash itself, it's either deliberate by the programmer, or a happy coincidence. IME it's almost always the latter, if it's portable at all (which isn't uncommon in my work).

(Also wanted to add that this isn't a unique property to Python either. Any "real" language typically has these same properties.)

Totally agree. You can avoid lots of this by using Bash built-ins, but that's more advanced/esoteric Bash development that most people aren't familiar with.

Thankfully, with the official deprecation of Python 2.7 and the slow march of progress I hope to be able to better standardize on Python 3 + stdlib (or similar).

That is true, but most languages do work on all of those things, e.g. For parts of the D ecosystem we have moved over to build scripts actually written in D, and they almost always work even though the makefiles and bash scripts are sometimes completely fucked whenever I fiddle with my computer. The best part is with the scripts in a real programming language (Python is good enough too), you can actually read them and show how they work to people coming from visual studio who can't read bash or make