From: Paul Hänsch Date: Thu, 10 Aug 2023 16:47:05 +0000 (+0200) Subject: implement redirect pragma X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=84f73eca9864a516dba6c0a8d90b9d45c94dfaad;p=shellwiki implement redirect pragma --- diff --git a/handlers/20_redirect.sh b/handlers/20_redirect.sh new file mode 100755 index 0000000..9f3497e --- /dev/null +++ b/handlers/20_redirect.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +case $PATH_INFO in + *"/["*"]") + return 1; + ;; +esac + +if acl_read ${PATH_INFO}; then + mdfile="$(mdfile "${PATH_INFO%/*}")" +else + return 1 +fi + +if [ "$mdfile" ]; then + REDIRECT="$( + sed -nE ' + s;^%redirect[ \t]+([[:graph:]][[:print:]]+)\r?$;\1;p; tQ; + b; :Q q; + ' "$mdfile" + )" +else + return 1 +fi + +if [ "$REDIRECT" ]; then + REDIRECT "$REDIRECT" +fi + +return 1