Any regex metacharacter in `SG_DIRBASE` will break this. I think you'll be better off checking if the first component of the result of `file(RELATIVE_PATH)` is `..`.