From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id C775123228 for ; Tue, 19 Mar 2024 12:08:59 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1710846539; b=DGf3/BM0tz/WYf/9yF3lL7IfqAnaqZZDXcuigJdSoLoom9kcn8wzM2ifHBK/1c+ShhrUD/lcv5 XQWE622Bx/12GCtSOOtDjV+RhW9MkPNx5RZ8LNc/IVDHc2PXNtIXFVw6Hdcu7FS1fm60zGzNGf xhH5EBI3bV/du+aQhDHlEqJS6C7ZMn35nT2L4Jt7gJFgYgKTNpCthzOa6Ho+5rtpj+OJ7qdXkM JjGjVrYO2SP9NOppUK+GH3VclP/xFh/E4bwN5W++a1AZ4PqtIe7AQ+siuCSuW7JO9BGl1bL6Vx Q71BBlMG8SbHKRDmyl/WNeZeu7/lDJ7BrOSqvczJ2keQiA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f46.google.com) smtp.remote-ip=209.85.218.46; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1710846539; bh=ARWQNR3TvY7NwSAEHd6gD2LJNoBAoVYsr516NwUZIMA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature:DKIM-Signature; b=ZaJT0uGcDpb6Af9f3fleWoZl1pe4g1aAN1DkamJIxpUgGm+vHtmzdhDE8PpGYRLk7ixhTuuJA+ OwBip/u/7QadxdhHqc3AgxH/2V+EIAtmw0v3QvV12UvAWK8oeMYCGPp33n0EsUA8lbbAc3iqTC kyGfWFST+LmYJ9hcpls5SaKa3P+dh5dN/neHjERf6JYrrkXy0QB/sTgXuOD5e74txsiYSbeGy0 J32m/DFR70+gi5nakvoCIQWALD8qVB9NefR6+zJNJyWqBq7KN3GCV+RfvLj3SmaSswz5IVtFa9 TABlxMWUtqjanTsbBfSUfubtTxhliT5apulFc5D6ZoCxaA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=qsXee8ZD0nxADr38o2rrzO4B1zpI4ih5Ef2bySJAYx4=; b=q4pQ2eBtLzCDbkuy3fn5wBO6oQ 6CXpRUh8OiwwQWvkOaGiTQMr/tLgD8gROx6Q0apUQVL15oRdPdsjbCs5j4zPtdtNFS3uZMTswjOEW ksuc8pPX2TpULxsBrmHgy/jTfIwx3AMAmajZynbROxckIYke2vE0euAo53vB7aaDeAmIVdhpM/jgY UYYGOsGM2GwlrwPFOzCHdr0g/yx4mMRDuJO08Gm/Vsv9MAWgpCKxw5Wr7qRk3bbdnH27bddXMXM31 FF0kHagswBY36bIlSeSVyrB1686GDuuStgS9inzV918+AYhgu+4A+9f+NjyXlrQp3cTihmUORoNnJ /lctIaVg==; Received: by zero.zsh.org with local id 1rmXL1-000LXd-7s; Tue, 19 Mar 2024 11:08:59 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f46.google.com) smtp.remote-ip=209.85.218.46; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ej1-f46.google.com ([209.85.218.46]:47134) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rmXKj-000LCf-QQ; Tue, 19 Mar 2024 11:08:45 +0000 Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a468004667aso572391366b.2 for ; Tue, 19 Mar 2024 04:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710846521; x=1711451321; darn=zsh.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qsXee8ZD0nxADr38o2rrzO4B1zpI4ih5Ef2bySJAYx4=; b=gNN2ZjgYCZugU7M1lmeoDg2OGt540lpRPyg2f3etvVNW6FjAfoTMp2M6V1Tx2y4sdb I2rcZ63UjlALjz3g1yQSPQxQl02QCuoupS0NatDJnTpsH2PXCogvtevINwxarL1O8Qsv USV3dsi3x615dDG3Bp5e6WXzpOBdeMWCjI6xU/3HtFQeww99OiGXinuQ9c5IyjhphP3d K+r4+OD1MTAy2YQtd5NSurmBt/2YUr1QaZk6GSNY8CxWac/jOIL+zrr8MYDGpSmkeL6T bwIz908EYR9s9CGantVQsk53S4jCVPlWgF0u5v/QfTQbOqjRE9NV5FC0QdkV+mYzZEKb x4pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710846521; x=1711451321; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qsXee8ZD0nxADr38o2rrzO4B1zpI4ih5Ef2bySJAYx4=; b=KLzhgMoABxscXXT5JHRwnjhHoOaw/p3uh+IY0+fmRw5zCdtn1NXO57i9UZmn/WXHLi rJdnI3+RPjoDSE7rZtLuyhwelxnkmVblww/yD8OM7rc/J878Zvh1hmk+y2Prn3S3hkhX o3D3PBJwGa9Z/goX2ZWvFyZ+TcmhHIiDYTp0LUctOBYz11CR0cn9cn1hMXJ3LBrNsx3U P7cbUerJHkKRaQDWrN0YTpVB8pP95o5Hk84hMBNOQWoBx66vglu+E2QGuKjh2qrM3cIr 8ac0qFw3XWfDtdLvumsGS2saLYm9t9PcyAMMD/MOqjEUCCABnLQCD8uGp+ZgZjeQbQdX LKww== X-Gm-Message-State: AOJu0YzToNspPQ33jqvDuut4bd3N+/46uHrnzF2mbqdqTPE5BPL3aTUK 1h3KnL1fetGAJeUcBahv42yHod85DcQLW8UJmL7ad4QBWlcNaGVlmjcDCvGeRHvb42INroYaj9M 9yVL5h9VXpeLtQW5gY2z9kKdWDO82YDoU X-Google-Smtp-Source: AGHT+IE5y3T3bk//XhdxTPh92No1r5WWArhFNExLWzyyILzQTXRAt/nzUacJcDGgQ3fFmj93g6FEJQwbNiD/Skz5ZpI= X-Received: by 2002:a17:906:c01:b0:a45:c931:5703 with SMTP id s1-20020a1709060c0100b00a45c9315703mr8003482ejf.70.1710846520951; Tue, 19 Mar 2024 04:08:40 -0700 (PDT) MIME-Version: 1.0 References: <20240313123817.GA3492761@cventin.lip.ens-lyon.fr> <20240315125317.GC3738413@cventin.lip.ens-lyon.fr> <20240319105745.GA4811@qaa.vinc17.org> In-Reply-To: <20240319105745.GA4811@qaa.vinc17.org> From: Mikael Magnusson Date: Tue, 19 Mar 2024 12:08:26 +0100 Message-ID: Subject: Re: HIST_IGNORE_DUPS also ignores command lines that differ by a space between quotes To: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52772 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: in hist.c: if ((isset(HISTIGNOREDUPS) || isset(HISTIGNOREALLDUPS)) && save > 0 && hist_ring && histstrcmp(chline, hist_ring->node.nam) =3D=3D 0) { /* This history entry compares the same as the previous. * In case minor changes were made, we overwrite the * previous one with the current one. This also gets the * timestamp right. Perhaps, preserve the HIST_OLD flag. */ he =3D hist_ring; newflags |=3D he->node.flags & HIST_OLD; /* Avoid re-saving */ freehistdata(he, 0); curline.histnum =3D curhist; and in hashtable.c (weird place for it): /* Compare two strings with normalized white-space */ /**/ int histstrcmp(const char *str1, const char *str2) { while (inblank(*str1)) str1++; while (inblank(*str2)) str2++; while (*str1 && *str2) { if (inblank(*str1)) { if (!inblank(*str2)) break; do str1++; while (inblank(*str1)); do str2++; while (inblank(*str2)); } else { if (*str1 !=3D *str2) break; str1++; str2++; } } return *str1 - *str2; } seems you could simply replace histstrcmp with strcmp and be happy. On Tue, Mar 19, 2024 at 11:58=E2=80=AFAM Vincent Lefevre wrote: > > On 2024-03-16 09:00:28 -0700, Bart Schaefer wrote: > > On Fri, Mar 15, 2024 at 5:53=E2=80=AFAM Vincent Lefevre wrote: > > > Note that spelling correction, which occurs *before* the line is put > > > in the history, detects quoted text and won't try to correct it. > > > > Spelling correction is actually performed by the lexer, at the same > > time as alias expansion. > > > > > it seems that "quoted status" can be taken into account at that point= . > > > > Not without separately storing both the original and lexed state of > > the text. > > I don't understand what you mean. The original text does *not* > seem to be used, as what is put in the history is the contents > *after* spelling correction. Moreover, the difference concerning > spaces between word splitting and quoted text is already taking > into account for HIST_REDUCE_BLANKS (which I'm using). I don't > see why it cannot be used for HIST_IGNORE_DUPS too. > > qaa:~> echo fil "foo bar" > zsh: correct 'fil' to 'file' [nyae]? y > file foo bar > > Recalling the command from the history: > > qaa:~> echo file "foo bar" > > As you can see, in the history, "fil" has changed to "file" as > corrected, and the 3 spaces after "fil"/"file" have been squashed > to a single one due to HIST_REDUCE_BLANKS. > > > Which is in fact done internally, but for hopefully obvious > > reasons is not done in the history file, which (during > > reading/writing) is where most duplicate elimination has to occur. > > The history file is not concerned here. This happens with "zsh -f", > where there is no history file: > > qaa:~> zsh -f > qaa% setopt HIST_IGNORE_DUPS > qaa% echo "a b" > a b > qaa% echo "a b" > a b > qaa% history > 1 setopt HIST_IGNORE_DUPS > 2 echo "a b" > > BTW, the zshoptions(1) man page correctly says "history list", > not "history file": > > HIST_IGNORE_DUPS (-h) > Do not enter command lines into the history list if they are > duplicates of the previous event. > > -- > Vincent Lef=C3=A8vre - Web: > 100% accessible validated (X)HTML - Blog: > Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) > --=20 Mikael Magnusson