Re: [alpine-devel] Shell scripting guidelines

Message ID
Sender timestamp
DKIM signature
Download raw message
11/05/2016 <u-ztsd@aetey.se>:
>- they are interpreted differently by different editors and
in different situations
>- they do not provide reliable indentation (because of varying
>interpretation by viewers/editors)
>- the classical interpretaion of 8 positions gives inefficient
>(and inflexible) large indentation, easily leading to long lines
>or/and line wrapping

Isn't that the whole point of tabs? I dunno, I don't want this to turn into a tab vs. spaces war. As <caoc@riseup.net> stated it is a very common practise and all the scripts follow that rule so far. Therefore I think it would be best to leave it as it is. At least for now.

>Depends on the situation. IMHO dangerous operations should become >canceled if the user can not spell the answer, otherwise you expose your >script among others to the user-in-a-hurry-typeahead or unintended multiline

You are right. Each situation you described requires different approach. But what is actually a dangerous situation? Do we let each programmer decide?

*Any operation manipulating with files could be seen as dangerous, hence the "exit" behavior is preferred.

>OTOH as long as there is a common library which e.g. defines echo
>via printf, making it deterministic, then it is as good as any
>other in-house shell function, if treated as such. I.e. you do not
>have to clean away all "echo"s from the scripts, if the scripts
>happen to rely on a function library.
Yeah, probably gonna do that.

>It is prudent to always put quotation marks around variable substitutions
>(like, no $ outside "").
Very good point. It's a must.

Thank you so much for your input, guys!

* $() vs ``


$() is recommended over `` as stated in POSIX. To avoid future problems, I'd like to see this rule "enforced" early on. If you disagree, let me now.

New rules:

* Use $() instead of ``
* Do not use echo, use printf instead
* Always surround variables in quotation marks " unless
===WIP name===