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 10434 invoked from network); 21 Jun 2020 13:33:54 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 21 Jun 2020 13:33:54 -0000 Received: (qmail 8925 invoked by alias); 21 Jun 2020 13:33:44 -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: 46090 Received: (qmail 5066 invoked by uid 1010); 21 Jun 2020 13:33:44 -0000 X-Qmail-Scanner-Diagnostics: from wout1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25842. spamassassin: 3.4.4. Clear:RC:0(64.147.123.24):SA:0(-2.6/5.0):. Processed in 4.73009 secs); 21 Jun 2020 13:33:44 -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: gggruggvucftvghtrhhoucdtuddrgeduhedrudektddgieejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkjghfofggtgfgsehtqh dttdertdejnecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceougdrshesuggrnhhi vghlrdhshhgrhhgrfhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpefhtdetfeehveeutd ehuddtieefgeettedtjedtffehudeiieejleetteekudetheenucfkphepjeelrddujeei rdefledrieelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepugdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Date: Sun, 21 Jun 2020 13:32:57 +0000 From: Daniel Shahaf To: zsugabubus Cc: zsh-workers@zsh.org Subject: Re: Useless assignment in _rm Message-ID: <20200621133257.2c4b679d@tarpaulin.shahaf.local2> In-Reply-To: <20200621120913.tk5caqwb3ob2r6wt@localhost> References: <20200621120913.tk5caqwb3ob2r6wt@localhost> 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=UTF-8 Content-Transfer-Encoding: quoted-printable zsugabubus wrote on Sun, 21 Jun 2020 14:09 +0200: > It caused issues with `rm -r anything`: > _rm:72: line: assignment to invalid subscript range > _rm:72: line: assignment to invalid subscript range >=20 CURRENT is 0 at that point which causes the error. In =C2=ABrm -r -f foo=C2=BB, CURRENT gets set to -1. I suppose anything that uses =C2=AB*::=E2=80=A6=C2=BB or =C2=AB*:::=E2=80= =A6=C2=BB should verify that CURRENT is >=3D1 before using it? > As much as I understand, the assignment is not needed because in the > next line the whole array will be reassigned. That's not quite right: the assignment uses $line. The patch causes =C2=ABrm foo=C2=BB when foo and foobar both exist to complete foobar; without the patch the completion is considered ambiguous. > diff --git a/Completion/Unix/Command/_rm b/Completion/Unix/Command/_rm > index ea9190d..82b382b 100644 > --- a/Completion/Unix/Command/_rm > +++ b/Completion/Unix/Command/_rm > @@ -69,7 +69,6 @@ _arguments -C -s -S $opts \ >=20 > case $state in > (file) > - line[CURRENT]=3D() > line=3D( ${line//(#m)[\[\]()\\*?#<>~\^\|]/\\$MATCH} ) > _files -F line && ret=3D0 > ;; Possible further improvements here: use ${(b)} in the assignment and use the =C2=ABzstyle =E2=80=A6 ignore-line other=C2=BB functionality rather= than reinvent it. However, as above, I think the fix to the bug is just to check CURRENT. Cheers, Daniel