Hi all, this is another question about adjusting my project to OpenWRT.
The project was initially written in Bash, then eventually I converted it to POSIX-compliant code. There is still no Luci interface, just the shell code. The total size of all essential scripts is currently about 170KB. Out of that, about 80KB is taken by scripts which are used for installation, uninstallation and post-installation configuration in case the user wants to adjust settings. The core functionality scripts which run after installation take the additional 90KB. That size is expected to grow as I'm planning to add support for nftables (currently the project only supports iptables).
So I'd like some input on what methods are preferable to reduce the size.
One thing that I could trim down is code comments. There are a lot of them in the code. Probably around 15-20% of the total size. I don't really want to do that since this will make the code less readable for someone who wants to understand what it's doing, and harder to maintain for me. If there is no choice, I suppose I could go for it.
There is also some code used for debugging embedded in the scripts which is not needed for the project to function but makes it much easier to maintain and develop. It takes probably 2-3% of the size. Not sure if removing it makes sense, at the expense of increased maintenance burden.
A third thing is code which processes command-line arguments and outputs a nice help message when the arguments don't make sense. Almost all scripts have that. That takes probably around 5-7% of the size.
Another thing that is possible to remove is error checking logic, which is a huge part of the code, I'd say at least 50%. Looking at some other projects around, I notice that they don't implement much error checking. In my opinion, this reduces the reliability of the code, more so because it's shell code, and again makes it more difficult to maintain. Does it make sense to strip it down?
Theoretically, I could also merge some scripts which should reduce the size of arguments handling code and error checking code without compromising reliability and user-friendliness. The downside would be that this would make the code less modular and more rigid, and the merged scripts will probably become quite long and thus harder to read. Currently the project is comprised of 14 scripts, 1 of them won't be used for OpenWRT and 2 are library scripts which won't benefit from merging. The additional 11 scripts are basically modules which call each other as needed.
Your input will be appreciated.