Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Jan 2024 18:31:11 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: ec13a838e685 - main - man: avoid unportable use of utilities
Message-ID:  <202401151831.40FIVBrY026495@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=ec13a838e6857585d3c3db70a0a67e337248ec28

commit ec13a838e6857585d3c3db70a0a67e337248ec28
Author:     Mohamed Akram <mohd.akram@outlook.com>
AuthorDate: 2024-01-15 18:27:04 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-01-15 18:30:37 +0000

    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
---
 usr.bin/man/man.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh
index 777726f880db..efb05603f912 100755
--- a/usr.bin/man/man.sh
+++ b/usr.bin/man/man.sh
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401151831.40FIVBrY026495>