2 ms·
Can you adopt a functional programming style when writing bash scripts, too? I think it's only a matter of mindset, not of language!
by amicofragile 6y ago
Can you adopt a functional programming style when writing bash scripts, too? I think it's only a matter of mindset, not of language!
- ktpsns 6y agoAnd it will certainly improve the debuggability of such code. The approaches are great, it would be nice to bundle these tools into a single shell script for easier usage. Or is there any reason why foreach() needs to be a file?
- amicofragile 6y agoNo, you can bundle functions like foreach, map, reduce and similar in your own `functional-bash.sh`, exporting them with `export -f`; so, if you include something like `. ~/bin/functional-bash.sh` in your `.bashrc` (or similar) file, these basic functions are available in all your scripts! I plan to write a blog post about this topic within a few days ;-)