[ale] Bash Scripts: When to break them into files

Jim Kinney jim.kinney at gmail.com
Tue Apr 27 08:04:34 EDT 2021

If a chunk of a script is useful by itself, I'll make it it's own file and just call it. I'm not concerned about efficiency of resources so calling a subshell for an external script is not a concern. Grep, sed, and awk are often launched many, many times in sequence anyway so what's another 10-40 subshells? :-)

An example:

I have one script that gathers the names of all nodes in the cluster. That can be called as input to push config changes or pull current settings or data. 
The multi-cluster version calls the same named script as above for each cluster, gathered using different, cluster-specific methods, to perform operations across all nodes in all clusters.
There are several, tiny, modifier scripts that can be selectively piped through for queue and node, node only, or queue only selection.

The modifier scripts were split out so I can reuse that functionality in the myriad ad hoc scripts I write daily for poke, prod,  and general break-fix operations.

On April 26, 2021 10:11:43 PM EDT, David Jackson via Ale <ale at ale.org> wrote:
>Hey Everyone,
>When do you guys feel that your bash scripts have gotten too long? 
>When do
>they need to be broken out into individual files, and when does doing
>make them less easy to maintain or follow?
>Also, how do you organize your scripts so they are easy for newcomers
>Your thoughts are appreciated!

Computers amplify human error
Super computers are really cool
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.ale.org/pipermail/ale/attachments/20210427/8d778371/attachment.htm>

More information about the Ale mailing list