Can you try the patch below? I'm interested in the output of the failing command, if it still occurs.
Interestingly, after applying the patch and re-running, nothing changes: It appears that "fetch" isn't even being called! It looks as if the problem isn't actually in the "fetch" script, then - but in whatever *should* call it. ("fetch" isn't called when running "bmake" or "bmake fetch", either normally or with PKG_DEBUG_LEVEL set)