diff options
author | Colin Watson <cjwatson@debian.org> | 2022-03-08 16:13:21 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2022-03-08 16:13:21 +0000 |
commit | cddae82c74ecdcc908adfd4730968d4ee237c13c (patch) | |
tree | ad2e74753f9a5fe4d89b1a9580e430d52a842ce8 /tools | |
parent | dbe96d093c7676e043790c9e7b2d68fec9df249c (diff) |
Apply various minor shell syntax improvements
* manual/print-options: Explicitly set `LANGUAGE=''` rather than
`LANGUAGE=`, pacifying shellcheck SC1007 which notes that this
construction might otherwise be misread.
* src/tests/manconv-odd-combinations: Use `printf %b` to pacify
shellcheck SC2059.
* src/tests/testlib.sh: Tell shellcheck which shell syntax to assume,
since this file has no `#!` line.
(run): Disable shellcheck SC2154; `abs_top_builddir` is always set by
the test runner.
(report): Remove unnecessary `$` before variable in arithmetic context.
(tools/checkman): Use `$(...)` for command substitution. Quote
variables properly where possible, and ignore shellcheck SC2068 in a
couple of other places.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/checkman | 14 | ||||
-rwxr-xr-x | tools/mkcatdirs | 27 |
2 files changed, 22 insertions, 19 deletions
diff --git a/tools/checkman b/tools/checkman index 4174473f..f93998d1 100755 --- a/tools/checkman +++ b/tools/checkman @@ -29,21 +29,22 @@ if test $# -ne 0 then manpath=$1 else - manpath=`manpath -q` + manpath=$(manpath -q) fi echo "Search for duplicates under:" >&2 -echo $manpath >&2 +echo "$manpath" >&2 -dups=`whatis -w -M $manpath "*" | sed -e 's/\([^(]*\) (\([^)]*\)).*/\2#\1/' | \ - sort | uniq -d` +dups=$(whatis -w -M "$manpath" "*" | + sed -e 's/\([^(]*\) (\([^)]*\)).*/\2#\1/' | \ + sort | uniq -d) for i in $dups do # split up the dup into the section/name components - args=`echo $i |tr '#' ' '` + args=$(echo "$i" | tr '#' ' ') # We only cater for two dups. Others will have to be fixed on a later run. # Find the locations of the dup'd files @@ -51,7 +52,8 @@ do file1= file2= - for file in `man -aw -M $manpath $args |sed -e 's/\([^ ]*\).*/\1/'` + # shellcheck disable=SC2086 + for file in $(man -aw -M "$manpath" $args |sed -e 's/\([^ ]*\).*/\1/') do if test "$file1" then diff --git a/tools/mkcatdirs b/tools/mkcatdirs index b8e3cc09..b7dbe13d 100755 --- a/tools/mkcatdirs +++ b/tools/mkcatdirs @@ -22,8 +22,8 @@ #PATH=.:/usr/local/bin:/usr/bin:/bin -progname=`basename $0` -here=`pwd` +progname=$(basename "$0") +here=$(pwd) test_only= # sort out the command line options @@ -41,7 +41,7 @@ else fi fi -( test "$1" = "-h" || test "$1" = "--help" ) && help=yes || help= +{ test "$1" = "-h" || test "$1" = "--help"; } && help=yes || help= if test "$help" || test -z "$test_only" then @@ -62,17 +62,17 @@ EOF exit 0 fi -for manpath in `manpath -qg | tr ':' ' '` +for manpath in $(manpath -qg | tr ':' ' ') do echo "Manual page hierarchy: $manpath" - catdir=`MANPATH=$manpath manpath -qc 2>/dev/null` - cd $manpath + catdir=$(MANPATH=$manpath manpath -qc 2>/dev/null) + cd "$manpath" subdirs= - for subdir in `echo man?*` + for subdir in $(echo man?*) do test -d "$subdir" && - subdirs="$subdirs `echo ${subdir} | sed -e 's,man,cat,'`" + subdirs="$subdirs $(echo "$subdir" | sed -e 's,man,cat,')" done echo "Cat page hierarchy: $catdir" @@ -84,7 +84,7 @@ do subs_ok= for subdir in $subdirs do - cd $catdir + cd "$catdir" test -d "$subdir" && subs_ok="$subs_ok $subdir" || subs_needed="$subs_needed $subdir" @@ -103,18 +103,19 @@ do catdirs= fi - cd $here + cd "$here" if test "$test_only" = "no" && test "$catdirs" then echo " " + # shellcheck disable=SC2086 echo "mkinstalldirs $catdirs" && mkinstalldirs $catdirs && echo "chown $owner $catdirs" && - chown $owner $catdirs && + chown "$owner" $catdirs && echo "chgrp $group $catdirs" && - chgrp $group $catdirs && + chgrp "$group" $catdirs && echo "chmod $mode $catdirs" && - chmod $mode $catdirs || + chmod "$mode" $catdirs || exit $? fi |