Skip to content

Commit

Permalink
utils: Small fixes of Bash util scripts (#1363)
Browse files Browse the repository at this point in the history
A selection of small fixes by Mega-Linter (combination of bash-exec, shellcheck, and esp. shfmt).
  • Loading branch information
wenzeslaus committed Feb 19, 2021
1 parent 567fa06 commit a0ccdb5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
12 changes: 5 additions & 7 deletions utils/dep_tree2sql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -282,7 +281,7 @@ EOF
dropdb "$dbname"
createdb "$dbname"

psql -n -q -d "$dbname" << EOF
psql -n -q -d "$dbname" <<EOF
-- ----------------------------------------------------------------------
Expand Down Expand Up @@ -579,4 +578,3 @@ UPDATE nonansi_counts
-- ----------------------------------------------------------------------
EOF

2 changes: 1 addition & 1 deletion utils/fix_typos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
22 changes: 7 additions & 15 deletions utils/module_synopsis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -97,7 +95,6 @@ find_menu_hierarchy()
echo "$PLACEMENT"
}


### execute the loop for all modules
for DIR in bin scripts ; do
cd $DIR
Expand Down Expand Up @@ -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.
Expand All @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -456,26 +452,22 @@ EOF

done


#### save footer
cat << EOF >> "${TMP}.tex"
\end{lyxlist}
\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
Expand Down

0 comments on commit a0ccdb5

Please sign in to comment.