def which(repository_ctx, cmd, default = None):
    """
    A wrapper around repository_ctx.which() to provide a fallback value. Doesn't %-escape the value!

    Args:
      repository_ctx: The repository context.
      cmd: name of the executable to resolve.
      default: Value to be returned when such executable couldn't be found.
    Returns:
      absolute path to the cmd or default when not found.
    """
    result = repository_ctx.which(cmd)
    return default if result == None else str(result)