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

Charles Shapiro hooterpincher at gmail.com
Tue Apr 27 14:29:25 EDT 2021


My rule of thumb is about 100 lines.  After that, I reach for a language
with better organizational tools.  Python, C++, and lua come to mind
first.   Data which is more than around the same amount should go into a
database, preferably postgresql.  Spreadsheets are Not Databases.

-- CHS

On Tue, Apr 27, 2021 at 12:08 PM Chuck Payne via Ale <ale at ale.org> wrote:

> So I use to have a big bash script for setup up. I have since broke it out
> to small scripts, for things that I can't do with Ansible.
>
> To me, smaller scripts make sense because you can troubleshoot issues
> easier.
>
> The question is this, does it make sense for you to pull out a function to
> be on its own? Then yes, small is better, and you can use that script for
> other things. Does the script need to call on everything or can you make
> outside calls?
>
> In your current script, do you have l exit 0 at the end so you know
> everything rn smoothly? Do you have like different exit number to should
> you were your script is failing?
>
> I will be honest, why I am moving more script to ansible if I can use
> ansible to replace. For things I can't, I try again for the smaller script
> so I can trouble shoot. I had one script that was 1300 lines of code. It
> was a mess even with comments to see where issues were.
>
> On Tue, Apr 27, 2021 at 11:33 AM Allen Beddingfield via Ale <ale at ale.org>
> wrote:
>
>> Microsoft Teams even works surprisingly well on Linux these days.  It is
>> our mandated internal communication method, remote work, meeting,
>> collaboration, etc... software at work.  I thought I wasn't going to like
>> it, but on openSUSE Leap it works fine.  Our past year of remote work would
>> have been a lot more difficult without it.
>>
>> --
>> Allen Beddingfield
>> Systems Engineer
>> Office of Information Technology
>> The University of Alabama
>> Office 205-348-2251
>> allen at ua.edu
>>
>>
>> ________________________________________
>> From: Ale <ale-bounces at ale.org> on behalf of Adrya Stembridge via Ale <
>> ale at ale.org>
>> Sent: Tuesday, April 27, 2021 10:21 AM
>> To: Atlanta Linux Enthusiasts
>> Cc: Adrya Stembridge
>> Subject: [EXTERNAL] Re: [ale] Bash Scripts: When to break them into files
>>
>> Zoom works perfectly on my debian based systems.
>>
>> On Tue, Apr 27, 2021 at 11:18 AM Steve Litt via Ale <ale at ale.org<mailto:
>> ale at ale.org>> wrote:
>> How about the more universally Linux-accessible Jitsi instead of Zoom?
>>
>> SteveT
>>
>>
>> Michael Potter via Ale said on Tue, 27 Apr 2021 09:49:06 -0400
>>
>> >We can have a zoom meeting sometime and I can do my bash presentation
>> >if there is interest.
>> >
>> >On Tue, Apr 27, 2021 at 8:04 AM Jim Kinney via Ale <ale at ale.org<mailto:
>> ale at ale.org>> wrote:
>> >
>> >> 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<mailto: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 so make them less easy to maintain or follow?
>> >>>
>> >>> Also, how do you organize your scripts so they are easy for
>> >>> newcomers to understand?
>> >>>
>> >>> Your thoughts are appreciated!
>> >>>
>> >>> Thanks!
>> >>> Dave
>> >>>
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org<mailto:Ale at ale.org>
>> https://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> https://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>>
>
>
> --
> Terror PUP a.k.a
> Chuck "PUP" Payne
> -----------------------------------------
> Discover it! Enjoy it! Share it! openSUSE Linux.
> -----------------------------------------
> openSUSE -- Terrorpup
> openSUSE Ambassador/openSUSE Member
> skype,twiiter,identica,friendfeed -- terrorpup
> freenode(irc) --terrorpup/lupinstein
> Register Linux Userid: 155363
>
> openSUSE Community Member since 2008.
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> https://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.ale.org/pipermail/ale/attachments/20210427/0e2d940d/attachment.htm>


More information about the Ale mailing list