try_sudo (lib/capistrano/recipes/deploy.rb)

    # File lib/capistrano/recipes/deploy.rb, line 129
    def try_sudo(*args)
      options = args.last.is_a?(Hash) ? args.pop : {}
      command = args.shift
      raise ArgumentError, "too many arguments" if args.any?

      as = options.fetch(:as, fetch(:admin_runner, nil))
      via = fetch(:run_method, :sudo)
      if command
        invoke_command(command, :via => via, :as => as)
      elsif via == :sudo
        sudo(:as => as)
      else
        ""
      end
    end