Once I discovered functions are pipeline-friendly, I started pipelining all the things. Almost any `for arg` can be re-designed as a `while read arg` with a function.
Here's what it can look like. Some functions I wrote to bulk-process git repos. Notice they accept arguments and stdin:
# ID all git repos anywhere under this directory
ls_git_projects ~/src/bitbucket |
# filter ones not updated for pre-set num days
take_stale |
# proc repo applies the given op. (a function in this case) to each repo
proc_repos git_fetch
Here's what it can look like. Some functions I wrote to bulk-process git repos. Notice they accept arguments and stdin:
Source: https://github.com/adityaathalye/bash-toolkit/blob/master/bu...The best part is sourcing pipeline-friendly functions into a shell session allows me to mix-and-match them with regular unix tools.
Overall, I believe (and my code will betray it) functional programming style is a pretty fine way to live in shell!