dotfiles/.local/bin/scripts/checkaccess

14 lines
328 B
Plaintext
Raw Normal View History

2021-09-21 20:32:35 +00:00
#!/bin/sh -e
# Checks whether the current user has rights to the respective file(s),
2021-09-18 19:53:14 +00:00
# even if it does not exist.
# First parameter defines which rights are required and is passed to "test".
2021-09-21 20:32:35 +00:00
flag=$1
while test $# -gt 1; do
shift
dir="$1"
while ! test -e "$dir"
do dir="$(dirname "$dir")"
done
test $flag "$dir"
2021-09-18 19:53:14 +00:00
done