#!/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 $flag "$dir" done