64f1406 elevated the sudo/doas check to the top level of the script, but since it's only used when -d isn't passed, that's a bit too universal.
Perhaps that commit should be reverted and detect_sudo_command >&2 should be invoked just after if [ -z "$NO_DEPS" ]; then and before the case statements