Fix problem with CURDIR on BSD systems