#!/bin/sh

helpdir1=/usr/share/alterator/help
helpdir2=/usr/share/install2/help

#turn off auto expansion
set -f

. /usr/share/alterator/build/backend3.sh

search_help()
{
    local languages="$1";shift
    local name="$1";shift
    local help_file=
    
    for lang in $languages; do
	for dir in "$helpdir1" "$helpdir2";do
	    help_file="$dir/$lang/$name.html"
	    if [ -s "$help_file" ]; then
		printf '(path "%s")\n' "$help_file"
		return 0
	    fi
	done
    done
    return 1
}

on_message()
{
	case "$in_action" in
		read)
			local languages="$(printf '%s' "$in_language" |tr ';' ' ') en_US"

			search_help "$languages" "$in__objects" ||
			search_help "$languages" "unknown" ||
			printf '(path #f)\n'

			;;
		*)
			echo '#f'
			;;
	esac
}


message_loop
