function permchk (){
if [ -z "$1" ]; then
echo "Enter path: ./test path"
else
namecal="$(basename ${1}).$(date +%F).$$"
touch ~/$namecal
truncate -s 0 ~/$namecal
result=$(sudo ls -ld ${1} >> ~/$namecal)
fi
}
permchk $1
if [[ $? -eq 0 && ! -z permchk ]]; then
echo "permission check completed."
vim ~/$namecal
fi