[LEDE-DEV] [PATCH v3 04/13] scripts: $/${} is unnecessary on arithmetic variables

Sebastian Moeller moeller0 at gmx.de
Thu Oct 6 07:05:48 PDT 2016

Hi Bastian, 

On October 6, 2016 2:09:01 PM GMT+02:00, Bastian Bittorf <bb at npl.de> wrote:
>* Sebastian Moeller <moeller0 at gmx.de> [06.10.2016 13:48]:
>> It might be not be necessary, but does it hurt? Are you concerned
>that the current practice will hide variables changing their "type"
>from arithmetic and that removing the $ prefix will silence this
>instead of giving an error message? Or does this change improve run
>time of the scripts noticeable? I am just asking, as a non-experts in
>shell coding it seems less error prone to always use
>e.g. this case:
>SUM=$(( A + B ))		# correct
>instead of SUM=$(( $A + $B ))	# old
>it is not about hurting, it's about make the code checkable.
>"every" parser will complain about this mistake, so satisfy them
>and we safe a few bytes 8-)

        Well, this might be correct, but if typical use is $A and the result of the computation still 10 then I would rather say the parser needs work. I could be wrong, and most likely are, but fixing working code to please a parser seems backwards, unless the common usage pattern truly has unwanted side effects. But again, I claim no expertise in these matters.

Best Regards

>bye, bastian

More information about the Lede-dev mailing list