[patch] shell/ash.c: mimics dash WRT set [+-]o

Denys Vlasenko vda.linux at googlemail.com
Tue May 6 18:57:32 UTC 2008


On Tuesday 06 May 2008 19:51, Cristian Ionescu-Idbohrn wrote:
> On Tue, 6 May 2008, Denys Vlasenko wrote:
> 
> > On Sunday 04 May 2008 14:23, Cristian Ionescu-Idbohrn wrote:
> > > It also replicates reality in some error messages, like:
> > >
> >
> > Applied, thanks
> 
> Great.
> 
> By the way, is there a style rule to hold to when it comes to use of
> curly brackets?  I find this in one and the same file shell/ash.c:
> 
> 	for (i = 0; i < NOPTS; i++)
> 		if (val) {
> 			out1fmt("%-16s%s\n", optnames(i), optlist[i] ? "on" : "off");
> 		} else {
> 			out1fmt("set %co %s\n", optlist[i] ? '-' : '+', optnames(i));
> 		}
> 
> and a few lines down, this:
> 
> 	for (i = 0; i < NOPTS; i++) {
> 		if (optletters(i) == flag) {
> 			optlist[i] = val;
> 			return;
> 		}
> 	}

There is no style rule for this.

I resist the urge to remove {} from one-statement ifs,
beacuse whenever one needs to add another statement,
they need to be added again. Unnecessary churn.

But if you write NEW code pieces, feel free to use
any variation.
--
vda



More information about the busybox mailing list