Bug#922423: initscripts: formatting of scripts

tito farmatito at tiscali.it
Tue Mar 18 06:46:16 GMT 2025


On Mon, 17 Mar 2025 21:31:22 +0100 (CET)
Thorsten Glaser <tg at evolvis.org> wrote:

> On Mon, 17 Mar 2025, Mark Hindley wrote:
> 
> > Scripts should follow the style produced by shfmt(1)
> 
> FWIW, never heard of that tool.
> 
> > - case indented
> 
> Don’t indent case, it’s useless and just adds clutter.
> You cannot have something other than the pattern inside, so:
> 
> case $foo in
> (bar)
> 	echo bla
> 	;;
> (*)
> 	echo nope
> 	;;
> esac
> 

Hi,  this breaks the visual matching of keywords and code blocks
making it harder to read, IMHO indentation has a point here:

case $foo in   OPENING KEYWORD and condition
	 (bar)         FIRST CONDITION
		echo bla   FIRST CODE BLOCK
 	;;                 END OF FIRST CONDITION
 	(*)              SECOND OR DEFAULT CONDITION
 		echo nope  SECOND OR DEFAULT CODE BLOCK
 	;;                END OF SECOND OR DEFAULT CODE BLOCK
 esac               CLOSING KEYWORD

Ciao,
Tito

> (If all scriptlets are extremely short, merging on less
> lines is possible.)
> 
> > - prefer '[ ]' to test(1) or builtin
> 
> I personally, as the maintainer of a shell and a plethora of
> scripts, recommend people to prefer test(1) over [ … ] instead
> because the latter “looks like” special syntax but [(1) isn’t
> (unlike [[ … ]], which they may also know), and that leads to
> insecure code, whereas test(1) looks more like a normal program
> whose arguments need proper quoting. I’m aware that this is a
> minority opinion, though.
> 
> http://www.mirbsd.org/man9/style has bits applying to shell
> scripts as well.
> 
> bye,
> //mirabilos




More information about the Debian-init-diversity mailing list