Reputation: 10405
Is there any lmitation on the size of a bash script? If yes, is there any effect of sourced scripts on the size?
Upvotes: 1
Views: 194
Reputation: 753970
If your script starts encroaching on 10K lines, it is (long past) time that you thought about writing some smaller scripts for it to use. However, the shell won't blink at a script that big.
So, the limit is on the comprehensibility of the script - if it gets too big, it gets unmaintainable. Pragmatically, there is no other limit on the size of the script; there is certainly no formal upper bound (so there's no magic number N where at N-1 bytes you are OK and at N bytes the shell says "too big").
If you want to find some examples of big scripts, look at the configure
scripts for just about any self-configuring open source product. The Perl 5.14.1 Configure
script is 23.6K lines and 528 KiB.
The top-level configure
script for GCC 4.6.2 is a mere 15.5K lines and 456 KiB; the configure script for its standard C++ library is 68.8K lines and 1806 KiB. These are generated scripts rather than hand-crafted scripts, but the shell still has to handle them.
Upvotes: 4