replace realpath with readlink -f to avoid dependency on realpath