savannah-cvs
[Top][All Lists]
Advanced

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

[Savannah-cvs] [797] style guide improvements


From: iank
Subject: [Savannah-cvs] [797] style guide improvements
Date: Tue, 9 Jul 2024 01:42:09 -0400 (EDT)

Revision: 797
          
http://svn.savannah.gnu.org/viewvc/?view=rev&root=administration&revision=797
Author:   iank
Date:     2024-07-09 01:42:07 -0400 (Tue, 09 Jul 2024)
Log Message:
-----------
style guide improvements

Fix that example did not capture an arg1 with spaces.

Other minor improvements.

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

Modified: trunk/sviki/fsf/bash-style-guide.mdwn
===================================================================
--- trunk/sviki/fsf/bash-style-guide.mdwn       2024-07-08 12:10:50 UTC (rev 
796)
+++ trunk/sviki/fsf/bash-style-guide.mdwn       2024-07-09 05:42:07 UTC (rev 
797)
@@ -72,7 +72,7 @@
 Before using any script, it should have no output from:
 
 ```
-shellcheck -x -e 2046,2068,2086,2206,2029,2033,2054,2164,2254 SCRIPT_FILE
+shellcheck -x -e 2046,2068,2086,2206,2029,2033,2054,2164,2254,2317 SCRIPT_FILE
 ```
 
 ### Reasons for the exceptions
@@ -117,6 +117,8 @@
 
 # 2164 = `cd` without condition for failure. Reason: We use automatic error
   handling.
+
+# 2317 = Unreachable code. Too many false positives.
 ```
 
 This is based on shellcheck version: 0.8.0 from Trisquel 11. A newer
@@ -473,7 +475,7 @@
 
 ```
 usage() {
-    cat <<EOF
+  cat <<EOF
 Usage: ${0##*/} [OPTIONS] ARG1 ARG2
 One line description
 
@@ -488,25 +490,26 @@
 
 ##### begin command line parsing ########
 
-bool_opt=false # default
-long_opt=foo # default
+bool_opt=false
+long_opt=foo
 temp=$(getopt -l help,long-opt: hbl: "$@") || usage 1
 eval set -- "$temp"
 while true; do
-    case $1 in
-        -b) bool_opt=true; shift ;;
-        -l|--long-opt) long_opt="$2"; shift 2 ;;
-        -h|--help) usage ;;
-        --) shift; break ;;
-        *) echo "$0: Internal error! unexpected args: $*" ; exit 1 ;;
-    esac
+  case $1 in
+    -b) bool_opt=true ;;
+    -l|--long-opt) long_opt="$2"; shift ;;
+    -h|--help) usage ;;
+    --) shift; break ;;
+    *) echo "$0: Internal error! unexpected args: $*" ; exit 1 ;;
+    shift
+  esac
 done
-read -r arg1 arg2 <<<"$@"
+arg1="$1"
+arg2="$2"
 if (( $# != 2 )); then
   echo "$0: error: expected 2 options, got $#." >&2
   exit 1
 fi
-
 ##### end command line parsing ########
 ```
 




reply via email to

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