On 2011-02-05 12:26 PM, Bastian Bittorf wrote:
> Some weeks ago, i started (undesired) a discussion[1,2]
> about how and why i think the base-files should get
> a refurbishment. I send several patches as a proposal,
> but it was not possible to apply them - the reasons are:
> 
> - the code changed nearly nothing, only the style
> - some people mentioned, that the old code was not good,
>   but it worked since years and changes in base are risky
> - it is not clear, if lowmem-targets are part of openwrt
>   (most of the patches uses lower mem and are faster)
> - there is no official coding style, that enforces the
>   use of specific ways how to do things
> - i mixed the reasons, why i wrote the new code
> 
> Here some words about this:
> 
> I like openwrt. There are many concepts i want to see
> in other distros. I'm not satisfied with many scripts
> and the way how people make a solution. Ofcourse this
> is my personal opinion, but there are good reasons to
> speak loud:
> 
> - clean code (not obfuscated)
> 
> This should be the most imported thing.
> It helps to debug.
> It lowers the entry-border.
> It makes it easier to change the code and do refactoring.
> (i have some ideas to modularize the functions/files, at the
> moment we often include files which we don't need)
> 
> It does NOT help to make a oneliner and 1000 users asks
> themself: what does THIS line? [3]
> 
> But while we are at it:
> - don't fork, if not needed. examples from /etc/init.d/compache:
> 
> [ "`cat /proc/swaps | grep 'ramzswap0'`" != "" ] && swapoff /dev/ramzswap0
> 
> better use:
> fgrep -q "ramzswap0" /proc/swaps || ...
I fully agree with changes like this.

> - use function_names to say what you want to do

> - use better shell builtins, instead of invoking another language
>   (e.g. awk, sed, lua) - only if there is no other option
I disagree with that. awk and sed are part of most typical shell
scripts, they've been around for ages and if awk and sed make something
expressible in one line instead of 10 without being unnecessarily
complex, then I consider that an improvement over writing weird
while/read/case loops.

> - using of shell builtins, leads to lower mem usage and are (mostly) faster
> 
> In the first discussion, i explained that awk is big and should not
> be in base-files. During experiments it turned out, that these are only
> some kilobytes. But the real reasons are explained above.
I think many of these scripts are simply prototypes - trying to evolve
them to better suit devices with 8 MB RAM is mostly a pointless
excercise, as many of them will be replaced with compact and much more
efficent c-code soon-ish. We will integrate new infrastructure for
starting/stopping/monitoring services and for generating config files
soon, which could work for even complex services without writing any
complex shell scripts - simply by having a proper description language.

> The next step can be:
> - make an official coding-style (at the moment much is mixed)
> - make an offical way, how to solve typical problems in scripts
> - make "base-files (experimental)" which can be selected in menuconfig
>   and i will maintain it. if people select it, they know the risk
> - vote for or against it
> - refactoring/refactoring/refactoring and try new concepts/ideas
I don't want a base-files fork in the official repository, it only adds
confusion when people want to make changes.

- Felix
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to