dotfiles/.local/bin/scripts/checkaccess

15 lines
350 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
2021-11-11 11:15:41 +00:00
test -L "$dir" ||
test $flag "$dir"
2021-09-18 19:53:14 +00:00
done