check the file existence using test -f
check if $pdfviewer is not ""
use = instead of ==
use $(..) instead of `..`
double quotes the variables
double quotes
fix tr argument
use ./*
use $(..) instead of `..`