Re:Show HN: Posixcube, a shell script automation framework a...
by schizoidboy on Sunday January 15, 2017 @02:52PM
(#13405996)
Yeah, I'll add some of the most common parameter expansion/substitution, string functions, array functions, etc. as APIs.
I had a thought yesterday for handling pipeline failures by using set -e in a sub-shell. I still need to test this, but something like:
(set -e; command1 | grep foo | grep bar | sed ...) || cube_check_return
Mostly [[ vs old [/test, advanced parameter expansion/substitution, arrays and maybe local variables.
It's been rather long since I attempted to get some dark magic working in posix shell - so I'm not entirely sure.
Either way, any proper scripting language will be more ergonomic to work in when you've reached beyond trivial (which posixcube already has).
There are simply too many anti-patterns to check for - too easy to miss quoting etc.
Python isn't great for (posix) system automation - but it's pretty good. And now I can trust all my systems to have python3. Then I feel it a bit hard to use shell beyond simple "command1, command2, command3"-type simple automation.
That said, it can be great fun to weave pipes and inputs in she'll, when you get it working. But as you've pointed out error handling with complex pipes isn't very good - and as always it's better to keep things simple, when possible.