savannah-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Savannah-cvs] [713] sytle guide, clearer wording


From: iank
Subject: [Savannah-cvs] [713] sytle guide, clearer wording
Date: Tue, 12 Dec 2023 21:13:13 -0500 (EST)

Revision: 713
          
http://svn.savannah.gnu.org/viewvc/?view=rev&root=administration&revision=713
Author:   iank
Date:     2023-12-12 21:13:11 -0500 (Tue, 12 Dec 2023)
Log Message:
-----------
sytle guide, clearer wording

Modified Paths:
--------------
    trunk/sviki/fsf/bash-style-guide.mdwn

Modified: trunk/sviki/fsf/bash-style-guide.mdwn
===================================================================
--- trunk/sviki/fsf/bash-style-guide.mdwn       2023-12-13 02:07:21 UTC (rev 
712)
+++ trunk/sviki/fsf/bash-style-guide.mdwn       2023-12-13 02:13:11 UTC (rev 
713)
@@ -312,14 +312,14 @@
 echo hello "$var"
 ```
 
-Note that `var=` as shown above would be a global variable.
-In a function body, it is best to declare variables as function-local,
-as noted in the 'Variables:' section. However, be sure not to set the
-variable in the declaration command, which would re-introduce the bug
-we are trying to avoid here (it bypass the trap - shellcheck issue SC2155).
-If the variable should be declared with `local`, `declare`, `readonly`, etc,
-declare it without a value, then set it's value separately (eg: `local var`,
-or `local tmp` in the previous example).
+Note that `var=` as shown above would be a global variable.  In a
+function body, it is best to declare variables as function-local, as
+noted in the 'Variables:' section. However, don't set the variable like
+`local x=3` because that has the same problem. Instead, `local x;
+x=3`. Shellcheck notices this as warning SC2155.  If the variable should
+be declared with `local`, `declare`, `readonly`, etc, declare it without
+a value, then set it's value separately (eg: `local var`, or `local tmp`
+in the previous example).
 
 ### Arithmetic expressions
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]