GNU bug report logs - #54290
zdiff can not handle options properly

Previous Next

Package: gzip;

Reported by: Lv Ying <lvying6 <at> huawei.com>

Date: Mon, 7 Mar 2022 12:12:02 UTC

Severity: normal

Merged with 35209, 54291, 54298

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 54290 in the body.
You can then email your comments to 54290 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gzip <at> gnu.org:
bug#54290; Package gzip. (Mon, 07 Mar 2022 12:12:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lv Ying <lvying6 <at> huawei.com>:
New bug report received and forwarded. Copy sent to bug-gzip <at> gnu.org. (Mon, 07 Mar 2022 12:12:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lv Ying <lvying6 <at> huawei.com>
To: <mertensb.mazda <at> gmail.com>, <eggert <at> cs.ucla.edu>
Cc: CAKxHvy1w=ubGoLSKcGe8mwU36MYjHvXLW_1j3=rBi9sLJNw8UQ <at> mail.gmail.com,
 fanwentao <at> huawei.com, bug-gzip <at> gnu.org
Subject: zdiff can not handle options properly
Date: Mon, 7 Mar 2022 17:29:51 +0800
As Bram Mertens mentioned in bug#35209:
"diff -y -W 200 /tmp/b1 /tmp/b2". But when passed to zdiff the space 
between "-W" and 200 causes the COLUMNS argument to be interpreted as a 
file:
zdiff -y -W 200 /tmp/b1 /tmp/b2
/bin/zdiff: 72: /bin/zdiff: cannot open 200: No such file

I reproduce this problem in gzip 1.11:
zdiff -y -W200 a.gz b.gz
aaaa							|	bbbb
zdiff -y -W 200 a.gz b.gz
zdiff: line 66: 200: No such file or directory

Also, file before options is not supported:
zdiff a.gz b.gz -y -W200
zdiff: line 66: -y: No such file or directory
diff a b -y -W 200
aaaa							|	bbbb

This is because zdiff.in implement option parse is simple. zdiff.in 
first parse all the options by while loop.
The use cmp="$cmp --" sperate options and file arguments. It is 
understandable that zdiff does not want to repeat the parameter parsing 
work of diff. So, use the simple option parse here.

However, the usage string said "Do comparisons like 'diff' does." Such 
usage will misldead the user just as bug#35209 mentioned.

There are two suggestions we may discuss:
1. update usage string, add detailed restricted instructions: e.g NO 
space between option and option argument, all the options should come 
before the filename parameter.
2. rewrite options parse function make it work just like diff.

-- 
Thanks!
Lv Ying




bug closed, send any further explanations to 54290 <at> debbugs.gnu.org and Lv Ying <lvying6 <at> huawei.com> Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Mon, 07 Mar 2022 22:01:02 GMT) Full text and rfc822 format available.

Merged 54290 54291. Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Mon, 07 Mar 2022 22:01:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gzip <at> gnu.org:
bug#54290; Package gzip. (Tue, 08 Mar 2022 15:57:02 GMT) Full text and rfc822 format available.

Message #12 received at 54290 <at> debbugs.gnu.org (full text, mbox):

From: Lv Ying <lvying6 <at> huawei.com>
To: <eggert <at> cs.ucla.edu>, <54290 <at> debbugs.gnu.org>
Cc: fanwentao <at> huawei.com, bug-gzip <at> gnu.org
Subject: Reply for zdiff-fix-arg-handling-bug.patch
Date: Tue, 8 Mar 2022 10:22:23 +0800
Hi Paul:

Thanks for your quick reply. I apply 
0001-zdiff-fix-arg-handling-bug.patch at the latest gzip code(commit 
2b281564e142c68acbdc) and test the problem.

This patch can fix options with argument(e.g zdiff -C 5). This patch did 
an interesting job to identify zidff options with argument([CDFISUWXx]), 
this case put option argument into cmp="$cmp '$2'". At last, cmp="$cmp 
--" separate options and filename arguments.

However this manual separation job can not handle filename before options.
zdiff -i -W 200 -U 5 a.gz b.gz
--- /dev/fd/5	2022-03-08 13:33:06.029980436 -0500
+++ -	2022-03-08 13:33:06.031632168 -0500
@@ -1 +1 @@
-aaaa
+bbbb
zdiff a.gz b.gz -i -W 200 -U 5
/root/community/gzip/zdiff: line 75: -i: No such file or directory

getopt command from util-linux can handle such situation. getopt can 
separate arguments and options by "--", even though arguments are before 
options.

Please add me when you reply this thread, so I can join this thread 
discuss easily.

-- 
Thanks!
Lv Ying




Information forwarded to bug-gzip <at> gnu.org:
bug#54290; Package gzip. (Tue, 08 Mar 2022 21:10:01 GMT) Full text and rfc822 format available.

Message #15 received at 54290 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Lv Ying <lvying6 <at> huawei.com>
Cc: fanwentao <at> huawei.com, 54290 <at> debbugs.gnu.org
Subject: Re: bug#54290: Reply for zdiff-fix-arg-handling-bug.patch
Date: Tue, 8 Mar 2022 13:09:26 -0800
[Message part 1 (text/plain, inline)]
On 3/7/22 18:22, Lv Ying via GNU gzip discussion and bug reports. wrote:

> However this manual separation job can not handle filename before options.
> ...
> getopt command from util-linux can handle such situation

We try to keep gzip portable to a wide variety of platforms, even those 
with ancient shells that lack getopt. I reworked zdiff.in to handle 
filenames before options (without using getopt) and installed the 
attached additional patch.

Please let us know of further problems by replying to this email and 
cc'ing to 54290 <at> debbugs.gnu.org (there should be no need to open a new 
bug report).
[0001-zdiff-fix-another-arg-handling-bug.patch (text/x-patch, attachment)]

Merged 54290 54291 54298. Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Tue, 08 Mar 2022 21:11:01 GMT) Full text and rfc822 format available.

Merged 35209 54290 54291 54298. Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Wed, 30 Mar 2022 00:08:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 27 Apr 2022 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 50 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.