Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4267417ybl; Tue, 21 Jan 2020 16:33:19 -0800 (PST) X-Google-Smtp-Source: APXvYqzG2r+Kwox2V3pPvBG/4JDAdnUddra0jhpjg485qMyZq1X5NfdSJ4W1WXhIRoKq3ilo9Ef/ X-Received: by 2002:aca:4106:: with SMTP id o6mr5039750oia.173.1579653198852; Tue, 21 Jan 2020 16:33:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579653198; cv=none; d=google.com; s=arc-20160816; b=jT2dMMTyqewQs4KcBlea3cmzIjCXsYsUiMQ8uaYTtBM87gUpBmQyvmq2LagsXOman5 MHtrjcS9qHu4pjMpigfL8Rd/QPVtoZr/o9Hlh6YjdaIa7ZSUvIO1WJLqc7yx5QKnlbwi W6dZsj3Rw3927mVgzsqeKrB2FCL0JWe8PCs7yEVSaL1g2VafEKdGyXYhLDkRQDwD3gBK cI0zDjjCVTwwvq/HOebuHS4Z+xy/FivRTiNOhTKAcAlceqHtrtV2LNwGJHK4YWJEP+/5 qufLsQaHt2r/1jGmgCT0C8sjhgBh/1Akva4i7+PdA5xYpmRllu45y3mSAGlvLNBmVRoH Se0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=DJC/caOwVfR2LAFwhDN8te/tMZBb509QuBHyr248398=; b=Kh0VnPiSMH6iEDMQVuYgaJeNpz6MO15o3RjHCblxa3xj2lDIqaorXrWX+YHQFzZP/O Pyr9a9bvij0OyMpqNAAYUlbjUieXxA39SQJ6nxsJVoIABvvAeLFasPMwKQ35ODxZEYKw 2xnjt8mJjJDehECFOHqKuBqM5hCaX7B8HCCdTnIENMqWWXHlCRaj9Rg4myib1/AQGL7g BjbuFmBKxUKNiQTVJDf4to1Xl6F4BSSFbVMkrE5Dr1Z0Fis0QIjN8cnXJytrqEGKnypB iXKdZoBW/t4j8VrP/uGuzeFPj6t4vYcujyAQzKAJRv/T2O98bTl8lSHrP+JrRsF/X3S2 mBUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FkNqdDl3; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b67si11401212oii.79.2020.01.21.16.32.56; Tue, 21 Jan 2020 16:33:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FkNqdDl3; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727969AbgAVAcx (ORCPT + 99 others); Tue, 21 Jan 2020 19:32:53 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:43383 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726876AbgAVAcx (ORCPT ); Tue, 21 Jan 2020 19:32:53 -0500 Received: by mail-oi1-f194.google.com with SMTP id p125so4470062oif.10 for ; Tue, 21 Jan 2020 16:32:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DJC/caOwVfR2LAFwhDN8te/tMZBb509QuBHyr248398=; b=FkNqdDl3USNVop1D576/b4snGQe/Srx7+oBfvdIM6doQlpWUh5dZCVyDOSJIl6C1Af 3NTd9Y8Fw31y3E3zItRK/Xgyhf7N1L0dz0w+s8T5awevNxhCjlCYuCf1+tvRgSXZMo+O 5AeoMAacAXNoiOiuNE4tyk0LDfAmg6dVdYminkmOG8Px2zAxhdJCro3hppREL6Umbstp rylDEk0blCzafy1o+DwQap8zilhuy1y8FoUbobDE9JL0yF0amuY8pXjFI5O7pZLl23TU Z0jfmOarhXP3eSSXWKocxuoC0v0+hXQvsSRHrNtE2t7CjZVQoJugro303sTWOnVFbWFR Ci8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DJC/caOwVfR2LAFwhDN8te/tMZBb509QuBHyr248398=; b=TMVXp76GPfE0e1GUpcdz3cc8QKmca4SAGKPNi1bL23z6nFW2EXIHAeRjHAkHn3hl/v G5zV66agcX+ZeEPdvK/fL+ufEaF50A0qOKIwaNrRHX+En25kdd5n++YkKVqr3nW8cFp7 GDMRpp1lGqipisGiw/MEV9XnoHIhYP26AMXP9uAMPr0cJGXuRbSsAKfalNC5gXH4h2wb G7pnuWmdXw/Lbt1SHGd99m2cLSZdeUm8WaACeoL80Hve/nwTKjEL36MDjDwTmAQLRoAI OZL/l96f+nR+bkHfqmZ4gwWaxNrkNbC6XESwkBILpMn8VkIjQgHbQ20CiXrFShqIWMw5 GGuA== X-Gm-Message-State: APjAAAVMMi/PB8ewAaaPrY5yhddmxOkOb2H0CNo+3fCM4yuUTp93IWqi aMHSPEg10axaUQ0SKAczv2Nb8QRn/3vm8xIwqBo= X-Received: by 2002:aca:4c15:: with SMTP id z21mr4926521oia.8.1579653172960; Tue, 21 Jan 2020 16:32:52 -0800 (PST) MIME-Version: 1.0 References: <20200118204423.494209-1-marijns95@gmail.com> In-Reply-To: <20200118204423.494209-1-marijns95@gmail.com> From: Luiz Augusto von Dentz Date: Tue, 21 Jan 2020 16:32:41 -0800 Message-ID: Subject: Re: [BlueZ PATCH] shared: shell: Only omit consecutive duplicate history lines. To: Marijn Suijten Cc: "linux-bluetooth@vger.kernel.org" , Luiz Augusto Von Dentz Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Marijn, On Sat, Jan 18, 2020 at 12:46 PM Marijn Suijten wrote: > > From: Marijn Suijten > > Change rl_handler to append duplicate history, as long as it isn't > identical to the last line. It prevents consecutive duplicates while > still having an accurate overview of the most recent commands used, > mimicking most modern shells. > > This addresses my only major gripe with bluetoothctl: pressing UP does > not retrieve the last typed command when it is a duplicate of something > else written (much) earlier in the history. It is especially noticeable > when needing the same command repeatedly. > --- > src/shared/shell.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/src/shared/shell.c b/src/shared/shell.c > index cfdcc76c4..2e094b8f1 100644 > --- a/src/shared/shell.c > +++ b/src/shared/shell.c > @@ -681,6 +681,7 @@ int bt_shell_release_prompt(const char *input) > static void rl_handler(char *input) > { > wordexp_t w; > + HIST_ENTRY *last; > > if (!input) { > rl_insert_text("quit"); > @@ -696,7 +697,9 @@ static void rl_handler(char *input) > if (!bt_shell_release_prompt(input)) > goto done; > > - if (history_search(input, -1)) > + last = history_get(history_length + history_base - 1); > + /* append only if input is different from previous command */ > + if (!last || strcmp(input, last->line)) > add_history(input); > > if (data.monitor) > -- > 2.25.0 Applied, thanks. -- Luiz Augusto von Dentz