printf '<ul class="pagelist">\n'
page_glob "$dir" \
| while read -r glob; do
- page_children "$glob" "$depth"
+ printf %s\\n "$glob"
+ page_children "$glob" "$((depth - 1))"
done \
| while read -r page; do
case $page in
}
page_children(){
- local page="${1%/}/" depth="${2:--1}"
+ local page="${1:-${PATH_INFO}}" depth="${2:-1}"
local glob pagedir IFS=''
+ page="${page%/}/"
[ "$depth" -eq 0 ] && return 0
- printf %s\\n "$page"
case $page in
/*)
/*) pagedir="$(PATH "$page")";;
*) pagedir="$(PATH "$PATH_INFO/$page")";;
esac
- [ -d "$_DATA/pages/$pagedir" -o -d "$_EXEC/pages/$pagedir" ] \
- && page_children "$page" "$((depth - 1))"
+ if [ -d "$_DATA/pages/$pagedir" -o -d "$_EXEC/pages/$pagedir" ]; then
+ printf %s\\n "$page"
+ page_children "$page" "$((depth - 1))"
+ fi
done
}