Re:Avoiding Bash frustration – Use Python for shell scripts
by jen20 on Sunday November 08, 2020 @08:16PM
(#25030549)
I have recently become convinced to use Python 3 scripts instead of all but trivial Bash scripts, however with one constraint: no libraries outside of the standard library for the minimum target platform, since requiring their installation is often non-trivial.
[ Parent
| on HN ]
Re:Avoiding Bash frustration – Use Python for shell scripts
by m463 on Monday November 09, 2020 @02:26AM
(#25032175)
That's exactly what I do.
And it turns out the standard library has a lot of depth to it, even on not-really-python-friendly platforms like macos.
I have a standard sort of "template" program that uses argparse and just fill it in.
It's nice to be able to iterate over a list of files without worrying about files with spaces in the name. I read and write json and csv files and use curses to colorize output.
You can do all these things in a shell script, but they tend to get messy.