return 1
;;
*/)
- if [ ! "$(mdfile "$PATH_INFO")" ]; then
+ if ! mdfile "$PATH_INFO" >&-; then
theme_error 404
elif ! acl_read "$PATH_INFO"; then
theme_error 403
REDIRECT "${_BASE}${PATH_INFO%\[view\]}"
;;
*/)
- if [ ! "$(mdfile "${PATH_INFO}")" ]; then
+ if ! mdfile "${PATH_INFO}" >&-; then
theme_error 404
elif ! acl_read "${PATH_INFO}"; then
theme_error 403
500) printf "%s\r\n" "Status: 500 Internal Server Error";;
esac
- if [ "$(mdfile "/[wiki]/$errno/")" ]; then
+ if mdfile "/[wiki]/$errno/" >&-; then
theme_page "/[wiki]/$errno/"
else
printf "Content-Length: 0\r\n\r\n"
fi
mdfile(){
+ # Check if page exists, if possible fall
+ # back to default page from installation
local page="$(PATH "$1")"
if [ -f "$_DATA/pages/$page/#page.md" ]; then
printf %s\\n "$_DATA/pages/$page/#page.md"
+ return 0
elif [ -f "$_EXEC/pages/$page/#page.md" ]; then
printf %s\\n "$_EXEC/pages/$page/#page.md"
+ return 0
else
return 1
- fi
+ fi 2>&-
+ # ^^ suppress error messages produced
+ # by printf when stdout was closed
}
size_human(){