Revision: 700 http://svn.savannah.gnu.org/viewvc/?view=rev&root=administration&revision=700 Author: iank Date: 2023-12-12 15:00:40 -0500 (Tue, 12 Dec 2023) Log Message: ----------- formatting fixes
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-12 19:58:04 UTC (rev 699) +++ trunk/sviki/fsf/bash-style-guide.mdwn 2023-12-12 20:00:40 UTC (rev 700) @@ -58,8 +58,10 @@ shellcheck -x -e 2046,2068,2086,2206,2029,2033,2054,2164,2254 SCRIPT_FILE ``` -The numbers are exceptions from the rules. The reasons for the exceptions: +### Reasons for the exceptions +The numbers are exceptions from the rules. + The following exceptions are for quoting variables. Shellcheck complains that unquoted variables will do splitting and globbing. You should simply know this and account for this it in your code. Most variables @@ -71,30 +73,36 @@ take untrusted input, or process files or variables which could have spaces, run shellcheck with no exceptions to verify quoting. - # 2046 = unquoted $(cmd) - # 2068 = Double quote array expansions to avoid re-splitting elements. - # 2086 = unquoted $var - # 2206 = unquoted $var in array=($var) - # 2254 = unquoted $var in case x in $var) +* # 2046 = unquoted $(cmd) +* # 2068 = Double quote array expansions to avoid re-splitting elements. +* # 2086 = unquoted $var +* # 2206 = unquoted $var in array=($var) +* # 2254 = unquoted $var in case x in $var) Miscellaneous exceptions: - # 2029 = Using unescaped variable in ssh call. Reason: This never +* # 2029 = Using unescaped variable in ssh call. Reason: This never works, warning is generally a false positive. - # 2032 = Warning about calling shell function over ssh. There are ways + +* # 2032 = Warning about calling shell function over ssh. There are ways for this to be a false positive, and we generally don't need a warning that shellcheck doesn't know if a command exists. - # 2033 = shell function as argument to another shell. Reason: This never + +* # 2033 = shell function as argument to another shell. Reason: This never works, warning is generally a false positive. - # 2054 = Array declaration contains a comma. Reason: This is warning of a + +* # 2054 = Array declaration contains a comma. Reason: This is warning of a mistake based on how other languages work, but this would never work as expected in bash and is a legitimate thing to do. - # 2164 = cd without condition for failure. Reason: We use automatic error + +* # 2164 = cd without condition for failure. Reason: We use automatic error handling. This is based on shellcheck version: 0.8.0 from trisquel 11. A newer shellcheck probably has new rules worth ignoring. +## Other shellcheck issues + If there is a need for something shellcheck warns about, use a directive to override the warning, eg: