From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bruno Haible Newsgroups: gmane.emacs.bugs Subject: bug#57129: 29.0.50; Improve behavior of conditionals in Eshell Date: Tue, 16 Aug 2022 15:35:17 +0200 Message-ID: <1871347.6tgchFWduM__3249.14183454297$1660657057$gmane$org@nimes> References: <835yish2l1.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39555"; mail-complaints-to="usenet@ciao.gmane.io" Cc: jporterbugs@gmail.com, larsi@gnus.org, 57129@debbugs.gnu.org To: Paul Eggert , bug-gnulib@gnu.org, Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 16 15:37:31 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oNwl8-000A7g-RJ for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Aug 2022 15:37:30 +0200 Original-Received: from localhost ([::1]:57782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNwl7-0001iN-Rb for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Aug 2022 09:37:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNwji-0000Ha-7M for bug-gnu-emacs@gnu.org; Tue, 16 Aug 2022 09:36:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55614) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oNwjh-0004V8-VO for bug-gnu-emacs@gnu.org; Tue, 16 Aug 2022 09:36:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oNwjh-0003c1-Mr for bug-gnu-emacs@gnu.org; Tue, 16 Aug 2022 09:36:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Bruno Haible Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Aug 2022 13:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57129 X-GNU-PR-Package: emacs Original-Received: via spool by 57129-submit@debbugs.gnu.org id=B57129.166065692513838 (code B ref 57129); Tue, 16 Aug 2022 13:36:01 +0000 Original-Received: (at 57129) by debbugs.gnu.org; 16 Aug 2022 13:35:25 +0000 Original-Received: from localhost ([127.0.0.1]:45363 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNwj6-0003b7-U1 for submit@debbugs.gnu.org; Tue, 16 Aug 2022 09:35:25 -0400 Original-Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.163]:44239) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNwj3-0003ax-WE for 57129@debbugs.gnu.org; Tue, 16 Aug 2022 09:35:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1660656918; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=hMDRdLRVf5Cez6XjVbIQ4bUDT9wQZfYKdY/cWRTTzNI=; b=hKZjP7aHOBErbd6Yjh/syzgLgHm7pZu+o0boUGWDk8wA8mCDyO2HGL8pE5iPErfX7D iC7tYWH2OXSQm6gjdpWH/FArxkUeDGTUGW3gxiOjp7KeiYrmSCbnVphell1u7fmPqh5B l0Xy73MvgR0H6n0wOzoKNTMXS72Kw2dSrK5LnIuhrgkQ3za5Sx4gyVGfCYS8itxorsos /NR1sUPH2QmSCqfUTHpCoT3vr0slE/hh4LHAJdkY/AOKje4eKjSRspbRAz102fL3ODNE X2NjX82mOUvpmwyQq5q7tf4u01tXuOnzyGkXVru7V0DnnNp3lzrScCo/5ygP/lyts5Sp z0Ew== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zG6tLj91pCR2L7hM6+Odi8PRCuZoP2/ZC83xg==" X-RZG-CLASS-ID: mo00 Original-Received: from nimes.localnet by smtp.strato.de (RZmta 47.47.0 AUTH) with ESMTPSA id g97246y7GDZIlZn (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 16 Aug 2022 15:35:18 +0200 (CEST) In-Reply-To: <835yish2l1.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:239936 Archived-At: Eli Zaretskii wrote: > The problem is that callers of > make-temp-file reasonably expect it to return a new name every call. > And evidently, it does that on GNU/Linux (not sure how, given that the > tempname.c code is supposed to be in glibc?). So if there's no > intention to change gen_tempname on non-glibc platforms so that it > doesn't repeat the same "random characters" upon each call, I think > Emacs should call a different function to generate "random" names of > temporary files, for consistency across platforms if not for other > reasons. You are making incorrect assumptions or hypotheses. I am adding the unit test below. It proves that (at least) on Linux, FreeBSD 11, NetBSD 7, OpenBSD 6.0, macOS, AIX 7.1, Solaris 10, Cygwin, and native Windows, gen_tempname *does* return a new file name on each call, with a very high probability. So, gen_tempname does *not* repeat the same "random characters" upon each call. 2022-08-16 Bruno Haible tempname: Add tests. * tests/test-tempname.c: New file. * modules/tempname-tests: New file. =========================== tests/test-tempname.c ========================== /* Test of creating a temporary file. Copyright (C) 2022 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* Written by Bruno Haible , 2022. */ #include #include "tempname.h" #include #include #include "macros.h" int main () { /* Verify that two consecutive calls to gen_tempname return two different file names, with a high probability. */ const char *templ18 = "gl-temp-XXXXXX.xyz"; char filename1[18 + 1]; char filename2[18 + 1]; strcpy (filename1, templ18); int fd1 = gen_tempname (filename1, strlen (".xyz"), 0, GT_FILE); ASSERT (fd1 >= 0); strcpy (filename2, templ18); int fd2 = gen_tempname (filename2, strlen (".xyz"), 0, GT_FILE); ASSERT (fd2 >= 0); /* With 6 'X' and a good pseudo-random number generator behind the scenes, the probability of getting the same file name twice in a row should be 1/62^6 < 1/10^10. */ ASSERT (strcmp (filename1, filename2) != 0); /* Clean up. */ close (fd1); close (fd2); unlink (filename1); unlink (filename2); return 0; } =========================== modules/tempname-tests ========================= Files: tests/test-tempname.c tests/macros.h Depends-on: unlink configure.ac: Makefile.am: TESTS += test-tempname check_PROGRAMS += test-tempname test_tempname_LDADD = $(LDADD) $(LIB_GETRANDOM) $(LIB_CLOCK_GETTIME) ============================================================================