diff --git a/404main b/404main index 3f3bb8f..9301f70 100755 --- a/404main +++ b/404main @@ -112,7 +112,7 @@ def main(): # Check if the amount of arguments is correct if len(sys.argv) < 2 or len(sys.argv) > 3 or sys.argv[1] in ('help', '-h', '--help'): print 'Usage: %s []' % sys.argv[0] - sys.exit(1) + sys.exit(0) cache = apt.cache.Cache() diff --git a/debian/changelog b/debian/changelog index bda6af3..105f335 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,8 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low * Add the beginnings of a test suite. (LP: #690386) - Switch to setuptools, to support setup.py test. - Test for that every script can run --help and return 0. + - 404main, merge-changelog, pull-debian-debdiff, pull-debian-source: + Return 0 after showing help. * ubuntutools/common.py: Remove https_proxy unsetting code, working around LP: #94130. @@ -30,7 +32,7 @@ ubuntu-dev-tools (0.109) UNRELEASED; urgency=low - Fix 'str' object has no attribute 'startwith' crash caused by a typo. - Fix crash if uploading to ubuntu without building the package before. - -- Stefano Rivera Wed, 22 Dec 2010 15:02:45 +0200 + -- Stefano Rivera Wed, 22 Dec 2010 16:52:55 +0200 ubuntu-dev-tools (0.108) experimental; urgency=low diff --git a/merge-changelog b/merge-changelog index 29e2d8a..d9f97fc 100755 --- a/merge-changelog +++ b/merge-changelog @@ -20,7 +20,7 @@ import sys, re -def usage(): +def usage(exit=1): print '''Usage: merge-changelog merge-changelog takes two changelogs that once shared a common source, @@ -28,7 +28,7 @@ merges them back together, and prints the merged result to stdout. This is useful if you need to manually merge a ubuntu package with a new Debian release of the package. ''' - sys.exit(1) + sys.exit(0) ######################################################################## # Changelog Management @@ -253,8 +253,10 @@ def deb_cmp(x, y): if __name__ == '__main__': + if len(sys.argv) > 1 and sys.argv[1] in ('-h', '--help'): + usage(exit=0) if len(sys.argv) != 3: - usage() + usage(exit=1) left_changelog = sys.argv[1] right_changelog = sys.argv[2] diff --git a/pull-debian-debdiff b/pull-debian-debdiff index bd5389f..e9e3e92 100755 --- a/pull-debian-debdiff +++ b/pull-debian-debdiff @@ -115,6 +115,13 @@ sub download_source return 1; } +sub usage +{ + my ($exit) = @_; + print "Usage: $0 PKG VERSION\n"; + exit $exit; +} + my $pkg = $ARGV[0]; @@ -123,8 +130,10 @@ my $just_fetch = ($ARGV[2] && $ARGV[2] eq "--fetch"); my $skip = $ARGV[2] || 1; $skip+=0; -if (!defined($pkg) || !defined($version)) { - die "Usage: $0 PKG VERSION\n"; +if (defined($pkg) && ($pkg eq '--help' || $pkg eq '-h')) { + usage(0); +} elsif (!defined($pkg) || !defined($version)) { + usage(2); } diff --git a/pull-debian-source b/pull-debian-source index aba22c8..297324f 100755 --- a/pull-debian-source +++ b/pull-debian-source @@ -27,10 +27,10 @@ use AptPkg::Version; die("Please install 'devscripts'\n") if(! grep -x "$_/dget", split(':',$ENV{'PATH'})); my($name)=basename($0); -my($package)=$ARGV[0] || &usage(); +my($package)=$ARGV[0] || &usage(2); my($help)=0; GetOptions('help' => \$help); -&usage() if($help); +&usage(0) if($help); my($release)=$ARGV[1] || 'unstable'; $release=&convertCodeName($release); &checkRelease($release); @@ -132,7 +132,9 @@ sub getDSC { } sub usage { - die("USAGE: $name [-h] [target release]\n"); + my($exit)=shift; + print("USAGE: $name [-h] [target release]\n"); + exit($exit); } sub invalidRelease { my($releases)=shift || die("Invalid Release!"); diff --git a/ubuntutools/test/test_help.py b/ubuntutools/test/test_help.py index a6812cf..f2ec524 100644 --- a/ubuntutools/test/test_help.py +++ b/ubuntutools/test/test_help.py @@ -25,17 +25,13 @@ import setup from ubuntutools.test import unittest BLACKLIST = { - '404main': 'Returns non-zero after help', 'check-symbols': 'No Help', 'edit-patch': 'No Help', 'grep-merges': 'No Help', 'lp-project-upload': 'Returns non-zero after help. Leaving u-d-t in LP: #524680', 'massfile': 'No Help. Leaves files in .', - 'merge-changelog': 'Returns non-zero after help', 'mk-sbuild': 'Fires up apt-get before showing help', 'pbuilder-dist-simple': 'No Help', - 'pull-debian-debdiff': 'Returns non-zero after help', - 'pull-debian-source': 'Returns non-zero after help', 'pull-revu-source': 'Throws Error', 'setup-packaging-environment': 'Throws Error', 'submittodebian': 'No Help',