dotfiles/.local/bin/scripts/checkaccess

15 lines
350 B
Bash
Executable File

#!/bin/sh -e
# Checks whether the current user has rights to the respective file(s),
# even if it does not exist.
# First parameter defines which rights are required and is passed to "test".
flag=$1
while test $# -gt 1; do
shift
dir="$1"
while ! test -e "$dir"
do dir="$(dirname "$dir")"
done
test -L "$dir" ||
test $flag "$dir"
done