Current user is $USER
. Previously I use:
if [ -e "$f" ] && [ `stat -c %U "$f"` != $USER ] \
|| [ -e "${f%/*}" ] && [ `stat -c %U "${f%/*}"` != $USER ]; then
to detect if file is owned by user (or dir if file is not yet exist).
But file can be owned by another and user still be able to modify it (group/other writable).
How can I check that file can be edited by current user by POSIX utilities (or if not possible - by GNU extensions)?
Do I need take into consideration extended attributes? How to deal with them?