From: Paul Hänsch Date: Tue, 17 May 2022 23:22:15 +0000 (+0200) Subject: acl detection in updated meta blocks X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=fc41cf7214c2c6ea3200c695a728e73afc74dc83;p=shellwiki acl detection in updated meta blocks --- diff --git a/acl.sh b/acl.sh index 74fc8dc..d232ea0 100755 --- a/acl.sh +++ b/acl.sh @@ -1,7 +1,7 @@ #!/bin/sh # ACL_OVERRIDE="${ACL_OVERRIDE:-Admin:read,write}" -ACL_DEFAULT="${ACL_DEFAULT:-All:read${BR}Known:read,write}" +ACL_DEFAULT="${ACL_DEFAULT:-Known:read,write${BR}All:read}" acl_cachepath='' acl_collection='' @@ -34,16 +34,21 @@ acl_collect(){ continue fi - n=20; while read -r head acl; do - if [ "$head" = "%acl" ]; then - acl_collection="${acl%${CR}}${BR}" - printf "%s\n" "${acl%${CR}}" - n=$((n+1)) - fi + acl="$(sed -En ' + s;\r$;;; + /^%acl([\t ]+.*)?$/bACL; + 20q; + b; - n="$((n - 1))" - [ "$n" -eq 0 ] && break - done <"$pagefile" + :ACL + s;(%(acl)?)?[\t ]*;; + p; n; s;\r$;;; + /^(%[ \t]+|%acl[ \t]+|[ \t]+)[^ \t\r]+$/bACL; + /^(%[ \t]*|%acl[ \t]*)$/bACL; + ' <"$pagefile")" + + printf %s\\n "${acl}" + acl_collection="${acl_collection}${acl}${BR}" done printf '%s\n' "$ACL_DEFAULT"