Page MenuHomeFreeBSD

bzip2: exit right after displaying license information
ClosedPublic

Authored by AMDmi3 on Dec 27 2016, 3:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jan 10, 10:00 AM
Unknown Object (File)
Nov 19 2024, 12:16 PM
Unknown Object (File)
Nov 15 2024, 5:09 AM
Unknown Object (File)
Sep 27 2024, 6:42 PM
Unknown Object (File)
Sep 23 2024, 6:48 AM
Unknown Object (File)
Sep 22 2024, 1:23 AM
Unknown Object (File)
Sep 20 2024, 9:22 AM
Unknown Object (File)
Sep 20 2024, 9:22 AM
Subscribers

Details

Summary

bzip2 --version or bzip2 --license (same thing) do not exit after
displaying version/license text as most utilities usually do, and
expects data to compress on stdin as if bzip2 was called without
arguments.

This leads to several problems in usage, such as:

Bogus error message when looking at version:

% bzip2 --version
bzip2, a block-sorting file compressor.  Version 1.0.6, 6-Sept-2010.

   Copyright (C) 1996-2010 by Julian Seward.

   This program is free software; you can redistribute it and/or modify
   it under the terms set out in the LICENSE file, which is included
   in the bzip2-1.0.6 source distribution.

   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
   LICENSE file for more details.

bzip2: I won't write compressed data to a terminal.
bzip2: For help, type: `bzip2 --help'.

Problems when examining this data, e.g. in scripts:

% bzip2 --version 2>&1 | head -1
bzip2, a block-sorting file compressor.  Version 1.0.6, 6-Sept-2010.
<hangs waiting for data>

So, let's make bzip2 exit right after it displays version/license information.

I've tried to contacted bzip2 author for a long time, but he's unresponsive.
For instance, Ubuntu has this problem fixed.

Related PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=199443

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

AMDmi3 retitled this revision from to bzip2: exit right after displaying license information.
AMDmi3 updated this object.
AMDmi3 edited the test plan for this revision. (Show Details)
contrib/bzip2/bzip2.c
1894 ↗(On Diff #23296)

Why not put the exit(0) at the end of the license() function instead? I see no invocations of this function that need to continue.

contrib/bzip2/bzip2.c
1894 ↗(On Diff #23296)
  1. It's bad practice to overload functions with things they should not do. license() shows license, it does not exit. Especially bad is to shove exit() down the call chain.
  2. This way when you look at this switch statement, it's apparent that the program exits after displaying the license. You don't need to examine license() body, it does which it's name tells.
  3. For consistence with usage() call below

Have you already tried to upstream that change?

Would be better to get that change upstreamed and then that we import into vendor the newer version or just apply the patch in the dist director from vendor and merge it back to contrib

In D8924#184833, @bapt wrote:

Have you already tried to upstream that change?

Would be better to get that change upstreamed and then that we import into vendor the newer version or just apply the patch in the dist director from vendor and merge it back to contrib

Like I've said in the summary, I've tried to contact upstream like a dozen of times. I've only got one reply in May 2015 not saying anything specific beside that "yes it should be fixed" and "there are no plans for 1.0.7 anytime soon", no replies for many emails after that. I take it as there's no more upstream.

dim edited edge metadata.

LGTM for the rest. @bapt, Dmitry already mentioned that the upstream author isn't responsive:

I've tried to contacted bzip2 author for a long time, but he's unresponsive.
For instance, Ubuntu has this problem fixed.

It looks like upstream is basically dead, and everybody moved on to xz...

This revision is now accepted and ready to land.Dec 28 2016, 1:30 PM
bapt edited edge metadata.