HACKER Q&A
📣 WhackyIdeas

Can a shell script ever be too big?


I am working on a PCKSH script which is verging on 5000 lines. It’s purpose is irrelevant, but OpenBSD server installation and configuration.

And it made me wonder… What is the consensus on large scripts? What is the largest script you have coded?


  👤 JohnFen Accepted Answer ✓
I didn't code it, but at a prior position part of my job was to maintain a 15,000 line sh script. (Why? Because it was part of a large enterprise product that had to run on a wide variety of platforms. That made a compiled binary problematic for installation and configuration.)

Honestly? It was fine. It was well-written and easy to follow and maintain.

I don't think the size of the script (or source code for a proper programming language) is nearly as important as how well-written it is.


👤 simonblack
As long as the function of the script is clear, I don't see any reason why it should be limited to any particular size at all. If your script is 5000 lines, so be it.

On the other hand, it would probably make sense to break that script into module-sized smaller scripts. The 'base' script would call those 'module' scripts as and when necessary.

Then each 'module' could be debugged and/or modified separately.