Revise r272363 by collapsing the tests into a for loop.

This has the side effect of ensuring that realpath is also run for the
nominal case of PORTSDIR=/usr/ports (assuming .CURDIR is a ports directory
that relies on /usr/ports but is not rooted in it).  This ensures that any
generated PORTSDIR used is always the actual location.

Submitted by:	jkim (different implementation)


git-svn-id: svn+ssh://svn.freebsd.org/base/head@272383 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f