man: avoid unportable use of utilities

echo -e is not portable. It can be replaced by printf %b (it works
only with the /bin/sh built-in echo, not /bin/echo anyway).
head -# is not portable, but head -n # is.

Replace these two things in three places total.

Signed-off-by: Mohamed Akram <mohd.akram@outlook.com>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1062
This commit is contained in:
Mohamed Akram 2024-01-15 11:27:04 -07:00 committed by Warner Losh
parent a5ef95cd22
commit ec13a838e6

View file

@ -312,7 +312,7 @@ man_check_for_so() {
# We need to loop to accommodate multiple .so directives.
while true
do
line=$($cattool "$manpage" | head -1)
line=$($cattool "$manpage" | head -n1)
case "$line" in
.so*) trim "${line#.so}"
decho "$manpage includes $tstr"
@ -897,11 +897,11 @@ search_whatis() {
bad=${bad#\\n}
if [ -n "$good" ]; then
echo -e "$good" | $MANPAGER
printf '%b\n' "$good" | $MANPAGER
fi
if [ -n "$bad" ]; then
echo -e "$bad" >&2
printf '%b\n' "$bad" >&2
fi
exit $rval