Skip to content

Commit

Permalink
man: fix redirect for locales and file arguments
Browse files Browse the repository at this point in the history
Use the locale-specific path for localized pages and the appropriate parent
directory for file arguments when handling redirects.

Signed-off-by: Mohamed Akram <[email protected]>
  • Loading branch information
mohd-akram committed Jan 9, 2024
1 parent bd9ddbc commit f265459
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions usr.bin/man/man.sh
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ manpath_warnings() {
fi
}

# Usage: man_check_for_so page path
# Usage: man_check_for_so path
# Returns: True if able to resolve the file, false if it ended in tears.
# Detects the presence of the .so directive and causes the file to be
# redirected to another source file.
Expand All @@ -313,7 +313,7 @@ man_check_for_so() {
.so*) trim "${line#.so}"
decho "$manpage includes $tstr"
# Glob and check for the file.
if ! check_man "$path/$tstr*" ""; then
if ! check_man "$1/$tstr*" ""; then
decho " Unable to find $tstr"
return 1
fi
Expand Down Expand Up @@ -497,7 +497,12 @@ man_find_and_display() {
unset use_cat
manpage="$1"
setup_cattool "$manpage"
if man_check_for_so "$manpage" "$(dirname \"$manpage"")"; then
p=$(cd "$(dirname "$manpage")" && pwd)
case "$(basename "$p")" in
man*|cat*) p=$p/.. ;;
*) p=$p/../.. ;;
esac
if man_check_for_so "$p"; then
found_page=yes
man_display_page
fi
Expand All @@ -516,7 +521,7 @@ man_find_and_display() {

# Check if there is a MACHINE specific manpath.
if find_file $p $sect $MACHINE "$1"; then
if man_check_for_so "$manpage" $p; then
if man_check_for_so $p; then
found_page=yes
man_display_page
if [ -n "$aflag" ]; then
Expand All @@ -530,7 +535,7 @@ man_find_and_display() {
# Check if there is a MACHINE_ARCH
# specific manpath.
if find_file $p $sect $MACHINE_ARCH "$1"; then
if man_check_for_so "$manpage" $p; then
if man_check_for_so $p; then
found_page=yes
man_display_page
if [ -n "$aflag" ]; then
Expand All @@ -543,7 +548,7 @@ man_find_and_display() {

# Check plain old manpath.
if find_file $p $sect '' "$1"; then
if man_check_for_so "$manpage" $p; then
if man_check_for_so $p; then
found_page=yes
man_display_page
if [ -n "$aflag" ]; then
Expand Down

0 comments on commit f265459

Please sign in to comment.