Selaa lähdekoodia

utils: Small fixes of Bash util scripts (#1363)

A selection of small fixes by Mega-Linter (combination of bash-exec, shellcheck, and esp. shfmt).
Vaclav Petras 4 vuotta sitten
vanhempi
commit
a0ccdb551e
3 muutettua tiedostoa jossa 13 lisäystä ja 23 poistoa
  1. 5 7
      utils/dep_tree2sql.sh
  2. 1 1
      utils/fix_typos.sh
  3. 7 15
      utils/module_synopsis.sh

+ 5 - 7
utils/dep_tree2sql.sh

@@ -37,7 +37,7 @@
 # You can then use simple queries such as:
 #
 # 	grass=> SELECT object FROM obj_imp WHERE symbol = 'I_get_target' ;
-# 	                               object                               
+# 	                               object
 # 	--------------------------------------------------------------------
 # 	 imagery/i.ortho.photo/photo.2image/OBJ.i686-pc-linux-gnu/target.o
 # 	 imagery/i.ortho.photo/photo.2target/OBJ.i686-pc-linux-gnu/target.o
@@ -51,7 +51,7 @@
 #
 # 	grass=> SELECT DISTINCT b.object FROM lib_exp a, obj_imp b
 # 	grass-> WHERE a.library = 'libgrass_form.6.1.cvs.so' AND a.symbol = b.symbol ;
-# 	                          object                           
+# 	                          object
 # 	-----------------------------------------------------------
 # 	 vector/v.digit/OBJ.i686-pc-linux-gnu/attr.o
 # 	 vector/v.digit/OBJ.i686-pc-linux-gnu/line.o
@@ -72,7 +72,7 @@
 # at the name) is to just sample it, e.g.:
 #
 # 	grass=> SELECT * FROM stlib_exp LIMIT 5 ;
-# 	      library      |   object   |    symbol     
+# 	      library      |   object   |    symbol
 # 	-------------------+------------+---------------
 # 	 libgrass_manage.a | add_elem.o | add_element
 # 	 libgrass_manage.a | ask.o      | ask_in_mapset
@@ -82,11 +82,10 @@
 # 	(5 rows)
 #
 
-
 tmpdir=/tmp/sql-grass
 dbname=grass
 
-if [ -n "$1" ] ; then
+if [ -n "$1" ]; then
 	builddir="$1"
 else
 	echo "Usage: del_tree2sql.sh <source directory>" >&2
@@ -282,7 +281,7 @@ EOF
 dropdb "$dbname"
 createdb "$dbname"
 
-psql -n -q -d "$dbname" << EOF
+psql -n -q -d "$dbname" <<EOF
 
 -- ----------------------------------------------------------------------
 
@@ -579,4 +578,3 @@ UPDATE nonansi_counts
 -- ----------------------------------------------------------------------
 
 EOF
-

+ 1 - 1
utils/fix_typos.sh

@@ -67,7 +67,7 @@ WORDS_WHITE_LIST="$WORDS_WHITE_LIST,THRESHHOLD_BILEVEL,THRESHHOLD_HALFTONE,THRES
 # GRASS GIS
 WORDS_WHITE_LIST="$WORDS_WHITE_LIST,thru"
 
-MYPATH=`pwd`
+MYPATH=$(pwd)
 
 touch $MYPATH/fix_typos/typos_whitelist.txt
 python3 $MYPATH/fix_typos/codespell/codespell.py -w -i 3 -q 2 -S $EXCLUDED_FILES \

+ 7 - 15
utils/module_synopsis.sh

@@ -49,15 +49,13 @@ if [ $? -ne 0 ] || [ -z "$TMP" ] ; then
     exit 1
 fi
 
-
 g.message "Generating module synopsis (writing to \$GISBASE/etc/) ..."
 
 SYNOP="$GISBASE/etc/module_synopsis.txt"
 
-OLDDIR="`pwd`"
+OLDDIR="$(pwd)"
 cd "$GISBASE"
 
-
 ### generate menu hierarchy
 
 #### fixme: no longer exists
@@ -97,7 +95,6 @@ find_menu_hierarchy()
   echo "$PLACEMENT"
 }
 
-
 ### execute the loop for all modules
 for DIR in bin scripts ; do
   cd $DIR
@@ -169,7 +166,6 @@ for MODULE in ps.map ; do
     fi
 done
 
-
 # these don't use the parser at all.
 cat << EOF >> "$TMP"
 g.parser: Full parser support for GRASS scripts.
@@ -195,11 +191,11 @@ cp "$SYNOP" "${TMP}.txt"
 g.message "Generating HTML (writing to \$GISBASE/docs/html/) ..."
 
 #### write header
-cat << EOF > "${TMP}.html"
+cat <<EOF >"${TMP}.html"
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-<title>`g.version | cut -f1 -d'('` Command list</title>
+<title>$(g.version | cut -f1 -d'(') Command list</title>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 <link rel="stylesheet" href="grassdocs.css" type="text/css">
 </head>
@@ -217,8 +213,8 @@ cat << EOF > "${TMP}.html"
 -->
 
 <center>
-<H1>`g.version | cut -f1 -d'('` Command list</H1>
-<h3>`date "+%e %B %Y"`</h3>
+<H1>$(g.version | cut -f1 -d'(') Command list</H1>
+<h3>$(date "+%e %B %Y")</h3>
 </center>
 <BR><BR><BR>
 
@@ -367,9 +363,9 @@ cat << EOF > "${TMP}.tex"
 \begin{center}\includegraphics[%
   width=0.3\textwidth]{grasslogo_vector.pdf}\end{center}
 
-\begin{center}{\huge `g.version | cut -f1 -d'('` Command list}\end{center}{\huge \par}
+\begin{center}{\huge $(g.version | cut -f1 -d'(') Command list}\end{center}{\huge \par}
 
-\begin{center}{\large `date "+%e %B %Y"`}\end{center}{\large \par}
+\begin{center}{\large $(date "+%e %B %Y")}\end{center}{\large \par}
 \bigskip{}
 
 
@@ -456,7 +452,6 @@ EOF
 
 done
 
-
 #### save footer
 cat << EOF >> "${TMP}.tex"
 \end{lyxlist}
@@ -464,18 +459,15 @@ cat << EOF >> "${TMP}.tex"
 \end{document}
 EOF
 
-
 \mv "${TMP}.tex" "$GISBASE/etc/module_synopsis.tex"
 \rm -f "${TMP}.txt"
 
-
 ##### FIXME
 # post generation tidy-up
 # - sort order isn't ideal. try 'sort -n'??
 #     fix: *.univar.sh, r.surf.idw2, v.to.rast3, r.out.ppm3, others..
 #####
 
-
 g.message "Converting LaTeX to PDF (writing to \$GISBASE/docs/pdf/) ..."
 
 for PGM in pdflatex ; do