# File lib/highline/menu.rb, line 295
    def select( highline_context, selection, details = nil )
      # add in any hidden menu commands
      @items.concat(@hidden_items)
      
      # Find the selected action.
      name, action = if selection =~ /^\d+$/
        @items[selection.to_i - 1]
      else
        l_index = "`"
        index = @items.map { "#{l_index.succ!}" }.index(selection)
        @items.find { |c| c.first == selection } or @items[index]
      end
      
      # Run or return it.
      if not @nil_on_handled and not action.nil?
        @highline = highline_context
        if @shell
          action.call(name, details)
        else
          action.call(name)
        end
      elsif action.nil?
        name
      else
        nil
      end
    ensure
      # make sure the hidden items are removed, before we return
      @items.slice!(@items.size - @hidden_items.size, @hidden_items.size)
    end