From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7413 invoked from network); 3 Jul 2020 13:42:32 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 3 Jul 2020 13:42:32 -0000 Received: (qmail 4394 invoked by alias); 3 Jul 2020 13:42:23 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: Sender: zsh-workers@zsh.org X-Seq: 46175 Received: (qmail 28138 invoked by uid 1010); 3 Jul 2020 13:42:23 -0000 X-Qmail-Scanner-Diagnostics: from out5-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25857. spamassassin: 3.4.4. Clear:RC:0(66.111.4.29):SA:0(-2.6/5.0):. Processed in 0.736875 secs); 03 Jul 2020 13:42:23 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrtdeigdeikecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkjghfofggtgfgsehtqhdttdertddvnecuhfhrohhmpeffrghnihgv lhcuufhhrghhrghfuceougdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvqeenuc ggtffrrghtthgvrhhnpeeugeevhfejleevvdetuedvfffhhffgudekffegteegvdeftdeu lefgleevvdelgfenucfkphepjeelrddujeeirdefledrieelnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugdrshesuggrnhhivghlrdhshhgr hhgrfhdrnhgrmhgv X-ME-Proxy: Date: Fri, 3 Jul 2020 13:41:46 +0000 From: Daniel Shahaf To: Mikael Magnusson Cc: Jonas =?UTF-8?B?QnLDpHV0aWdhbQ==?= , zsh-workers@zsh.org Subject: Re: [Bug] incorrect warning when I type rm /* Message-ID: <20200703134146.67928fd6@tarpaulin.shahaf.local2> In-Reply-To: References: <7438d554-ae4d-01c9-84c1-993227efd6f4@braeutigamj.de> <20200701110025.38f498d5@tarpaulin.shahaf.local2> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Mikael Magnusson wrote on Wed, 01 Jul 2020 13:33 +0200: > On 7/1/20, Daniel Shahaf wrote: > > I haven't figured out how to write a test for this (short of using > > expect(1) or so). =20 >=20 > zpty_start and variants as in W02jobs, X02zlevi and others? The following works, but I'm sure there's a more elegant way to do it. 8<--8<-- =46rom d2aed981ed378c5634b5fcdfd578acee40d59841 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 3 Jul 2020 13:31:10 +0000 Subject: [PATCH 1/3] Add a unit test for the RM_STAR_SILENT option. --- Test/E01options.ztst | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Test/E01options.ztst b/Test/E01options.ztst index 70736f444..a1b564327 100644 --- a/Test/E01options.ztst +++ b/Test/E01options.ztst @@ -57,7 +57,6 @@ # PROMPT_CR # PUSHD_SILENT # REC_EXACT -# RM_STAR_SILENT # RM_STAR_WAIT # SHARE_HISTORY # SINGLE_LINE_ZLE @@ -92,6 +91,9 @@ catpath=3D$(which cat) lspath=3D=3Dls =20 + # If the module fails to load, individual test points will skip. + zmodload zsh/zpty 2>/dev/null || true=20 + %test =20 # setopt should move on to the next operation in the face of an error, b= ut @@ -1423,3 +1425,26 @@ F:If this test fails at the first unsetopt, refer to= P01privileged.ztst. (( UID =3D=3D EUID )) fi 0:PRIVILEGED sanity check: default value is correct + + if zmodload -e zsh/zpty 2>/dev/null; then + for target_dir target_pattern in \ + '.' '*' + do + before=3D`ls -a -- $target_dir` + zpty subshell $ZTST_testdir/../Src/zsh -f + [[ $PWD =3D=3D */options.tmp ]] || return 1 # Sanity check before ca= lling rm(1). + zpty -w subshell "rm $target_pattern" + zpty -w subshell 'n' + sleep 1 + zpty -rt subshell REPLY # "${PS1} rm *" + zpty -rt subshell REPLY && print -r -- ${REPLY%%$'\r\n'} + zpty -d subshell + after=3D`ls -a -- $target_dir` + [[ $before =3D=3D $after ]] || return 1 + done + else + ZTST_skip=3D"the zsh/zpty module is not available" + fi + BEL=3D$'\a' +0q:RM_STAR_SILENT +*>zsh: sure you want to delete all 15 files in ${PWD:h}/options.tmp \[yn\]= \? ${BEL} =46rom 6a83700ee1f5f08c17c8438c66bb3fff48060182 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 3 Jul 2020 13:37:46 +0000 Subject: [PATCH 2/3] Add a regression test for 46169: the RM_STAR_SILENT lo= gic processes the current directory rather than the root directory. The bug will be fixed in the next commit. --- Test/E01options.ztst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Test/E01options.ztst b/Test/E01options.ztst index a1b564327..053affeed 100644 --- a/Test/E01options.ztst +++ b/Test/E01options.ztst @@ -1428,7 +1428,8 @@ F:If this test fails at the first unsetopt, refer to = P01privileged.ztst. =20 if zmodload -e zsh/zpty 2>/dev/null; then for target_dir target_pattern in \ - '.' '*' + '.' '*' \ + '/' '/*' do before=3D`ls -a -- $target_dir` zpty subshell $ZTST_testdir/../Src/zsh -f @@ -1446,5 +1447,6 @@ F:If this test fails at the first unsetopt, refer to = P01privileged.ztst. ZTST_skip=3D"the zsh/zpty module is not available" fi BEL=3D$'\a' -0q:RM_STAR_SILENT +0qf:RM_STAR_SILENT *>zsh: sure you want to delete all 15 files in ${PWD:h}/options.tmp \[yn\]= \? ${BEL} +*>zsh: sure you want to delete all <-> files in / \[yn\]\? ${BEL} =46rom 81b1f0018d2557aa607080570ea1d78237c006c7 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 3 Jul 2020 13:38:58 +0000 Subject: [PATCH 3/3] Fix the RM_STAR_SILENT bug from the parent commit. --- Src/exec.c | 2 +- Test/E01options.ztst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Src/exec.c b/Src/exec.c index 045b5d2b9..7120a2c34 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3401,7 +3401,7 @@ execcmd_exec(Estate state, Execcmd_params eparams, int rmall; =20 s[l - 2] =3D 0; - rmall =3D checkrmall(s); + rmall =3D checkrmall(l =3D=3D 2 ? "/" : s); s[l - 2] =3D t; =20 if (!rmall) { diff --git a/Test/E01options.ztst b/Test/E01options.ztst index 053affeed..c59509f2e 100644 --- a/Test/E01options.ztst +++ b/Test/E01options.ztst @@ -1447,6 +1447,6 @@ F:If this test fails at the first unsetopt, refer to = P01privileged.ztst. ZTST_skip=3D"the zsh/zpty module is not available" fi BEL=3D$'\a' -0qf:RM_STAR_SILENT +0q:RM_STAR_SILENT *>zsh: sure you want to delete all 15 files in ${PWD:h}/options.tmp \[yn\]= \? ${BEL} *>zsh: sure you want to delete all <-> files in / \[yn\]\? ${BEL}