diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/pmdk/utils/check-manpage | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pmdk/utils/check-manpage')
-rwxr-xr-x | src/pmdk/utils/check-manpage | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/pmdk/utils/check-manpage b/src/pmdk/utils/check-manpage new file mode 100755 index 000000000..d0c0d4d2e --- /dev/null +++ b/src/pmdk/utils/check-manpage @@ -0,0 +1,62 @@ +#!/bin/bash +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2019, Intel Corporation + +# check-manpage -- a tool to check a single man page against errors +# +# While it can handle multiple files, it's recommended to use +# check-manpages instead. +set -e + +check_link() +{ + [ $(wc -l <"$file") = 1 ] || + { echo ".so link isn't the only line" && return; } + link=$(cat "$file") + link=${link#.so } + [ "${link##*/}" = "$link" ] || + grep -q '^\.so man\([0-9]\)/[a-z0-9+_-]\+\.\1$' "$file" || + { echo ".so link directory is not matching manX" && return; } + [ -e "${link##*/}" ] || + { echo ".so link target doesn't exist: ${link##*/}" && return; } +} + +for m in "$@"; do + dir="$(dirname $m)" + file="$(basename $m)" + [ -n "$dir" ] && pushd "$dir" >/dev/null + + if grep -q '^\.so' "$file"; then + err=$(check_link) + [ -z "$err" ] || { + echo >&2 "$file: $err" + FAILED=1 + } + popd >/dev/null 2>/dev/null + continue + fi + + # man can emit warnings and errors. Even non-fatal errors are normally + # suppressed if a pager is in use (ie, all interactive usage). Common + # messages include an unknown macro, an unbreakable line, etc. + err=$(MANWIDTH=80 man --warnings -E UTF-8 -l -Tutf8 -Z "$file" 2>&1 >/dev/null| + grep -v 'cannot adjust line' || true) + [ -z "$err" ] || { + echo >&2 "$file: $err" + FAILED=1 + } + + # If a "NAME" section exists, call lexgrog to see if it's properly + # formatted. + if grep -q '^\.SH NAME' "$file"; then + if ! lexgrog "$file" >/dev/null; then + # lexgrog doesn't give any interesting messages. + echo 2>&1 "lexgrog failed on $file" + FAILED=1 + fi + fi + + popd >/dev/null 2>/dev/null +done + +exit $FAILED |