File: mansyntax.sh

package info (click to toggle)
libssh2 1.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,504 kB
  • sloc: ansic: 46,104; sh: 6,164; makefile: 348; cpp: 120; perl: 65; lisp: 33; awk: 23
file content (45 lines) | stat: -rwxr-xr-x 957 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
# Copyright (C) The libssh2 project and its contributors.
# SPDX-License-Identifier: BSD-3-Clause

set -e
set -u

# Written by Mikhail Gusarov
#
# Run syntax checks for all manpages in the documentation tree.
#
# Requirement on macOS: brew install man-db
#

command -v gman >/dev/null 2>&1 && man() { gman "$@"; }

dstdir="${builddir:-$PWD}"
mandir="$(dirname "$0")/../docs"

ec=0

#
# Only test if suitable man is available
#
if command -v grep >/dev/null 2>&1 && \
   man --help 2>/dev/null | grep -q warnings; then

  trap 'rm -f "$dstdir/man3"' EXIT HUP INT TERM

  ln -sf "$mandir" "$dstdir/man3"

  for manpage in "$mandir"/libssh2_*.*; do
    echo "$manpage"
    warnings=$(LANG=en_US.UTF-8 MANWIDTH=80 man -M "$dstdir" --warnings \
      -E UTF-8 -l "$manpage" >/dev/null 2>&1)
    if [ -n "$warnings" ]; then
      echo "$warnings"
      ec=1
    fi
  done
else
  echo 'mansyntax: Required tool not found, skipping tests.'
fi

exit "$ec"