IFS= read -rd '' real_target < <("${REALPATH}" --canonicalize-missing --no-symlinks --zero -- "${target}")

Safe reading from a subshell has never been easier.

Bash scripting is building a bomb shelter with fused mines instead of bricks.
@oleksandr Friends don't let friends write bash scripts.