Comment 1 for bug 246816

Revision history for this message
orbisvicis (orbisvicis) wrote : Re: fix

change the affected section to this:
# by: orbisvicis

manpath=$(manpath -g)

# Set the bash delimiter
# Spaces are mandatory when creating the array so bash does not becore confused
pathArray=( $manpath )
unset IFS

# From the bash man-pages
# Allow patterns which match no files to expand to a null string rather than themselves
shopt -s nullglob
for path in "${pathArray[@]}"
        # fixing the symlink issue: symlinks to directories will be considered empty. Undesirable if symlink points outside manpath
        # Must also check that the new link value is not already part of the manpath, dont want to give swish++ duplicate paths
        # requires readlink
        if [[ -h $path ]];then
                echo -n "symlink: "
                # This works here due to read order, might not work in other versions/shells
                if [[ $manpath = *$(readlink -n --canonicalize $path)* ]];then
                        echo -n "duplicate,ignored: "
                        echo -n "redirected to: "
                        path=$(readlink -n --canonicalize $path)
        # verify that the directory exists and contains the /man*/ subdirectories
        # Note that this will return a false (no subdirectories) for symlinks as they are treated as files
        # *this can make a difference if the link is not included in the manpath
        (( ${#pathGlob[*]} )) && pathStringExist+=$path":" || echo $path": no \"man*\" subdirectories"
        # Note that now ${path[@]} holds all the elements that matches the glob
        # This is useful for performing operations using ${path[@]}
        #echo ${pathGlob[@]}
# Unset the nullglob option
shopt -u nullglob

pathArrayExist=( $pathStringExist )
unset IFS

echo "${pathArrayExist[@]}"

if [[ -e /var/cache/man2html/ ]] && [[ -x /usr/bin/index++ ]];then
        if [[ -e /var/cache/man2html/man2html.swish++.index ]];then
                rm /var/cache/man2html/man2html.swish++.index* /var/cache/man2html/manindexh* /var/cache/man2html/whatish-*

        echo "see /usr/share/man2html for configuration options"
        index++ --config-file=/usr/share/man2html/swish++.conf "${pathArrayExist[@]}"
        echo "Done, recommend restarting webserver"