X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=tools.sh;h=e40e25f4be075bb97589fc6415e09c3c2dc5b025;hb=0e2b2e5a68f0e5a32bc4e7d869b475b744582643;hp=926c7e4e3bdf51ed763aa55b862dd25d53bdabfb;hpb=e83851d3bdcb41a24687a1579e35dcfa39db4722;p=shellwiki diff --git a/tools.sh b/tools.sh index 926c7e4..e40e25f 100644 --- a/tools.sh +++ b/tools.sh @@ -47,11 +47,11 @@ page_glob(){ } 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 /*) @@ -70,7 +70,9 @@ page_children(){ /*) 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 }