>>26077UNIXbrains will see:
ls -F $sitedir/./$req_paths_list >[2]/dev/null \
| {
sed $dirfilter'/\/[^_.\/][^\/]*(\.(md|txt|html)|\/)$/!d; s!^'$sitedir'!!; '$dirclean
if(! ~ $#synth_paths 0) echo $synth_paths | tr ' ' $NEW_LINE
} | sort -u | awk -F/ '
function p(x, y, s) { for(i=0; i < x-y; i+=1) print s }
BEGIN { lNF=2; print "<ul>" }
{
d = ""
if(match($0, "/$"))
d = "/"
sub("/$", "") # Strip trailing / for dirs so NF is consistent
p(NF, lNF, "<li><ul>")
p(lNF, NF, "</ul></li>")
lNF = NF
bname = $NF d
path = $0 d
gsub(/[\-_]/, " ", bname)
# To avoid false matches add trailing / even for plain files to act as delimiter
pa = path
gsub(/[^\/]$/, "&/", pa)
if(index(ENVIRON["req_path"] "/", pa) == 1)
print "<li><a href=\"" path "\" class=\"thisPage\">»<i> " bname "</i></a></li>"
else
print "<li><a href=\"" path "\">› " bname "</a></li>"
}
END { p(lNF, 2, "</ul></li>"); print "</ul>" }'
And think that it is easy to understand and sane (this is a single command)