From: Zac Medico Date: Sat, 3 Aug 2013 01:02:19 +0000 (-0700) Subject: filter-bash-environment.py: don't use optparse X-Git-Tag: v2.2.0_alpha192~6 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b919259cc54830e6d4ffbfa3aa878f16f4c3c016;p=portage.git filter-bash-environment.py: don't use optparse --- diff --git a/bin/filter-bash-environment.py b/bin/filter-bash-environment.py index b9aec96d0..3d4b3ecbb 100755 --- a/bin/filter-bash-environment.py +++ b/bin/filter-bash-environment.py @@ -1,10 +1,9 @@ #!/usr/bin/python -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import codecs import io -import optparse import os import re import sys @@ -126,10 +125,19 @@ if __name__ == "__main__": "intact. The PATTERN is a space separated list of variable names" + \ " and it supports python regular expression syntax." usage = "usage: %s PATTERN" % os.path.basename(sys.argv[0]) - parser = optparse.OptionParser(description=description, usage=usage) - options, args = parser.parse_args(sys.argv[1:]) + args = sys.argv[1:] + + if '-h' in args or '--help' in args: + sys.stdout.write(usage + "\n") + sys.stdout.flush() + sys.exit(os.EX_OK) + if len(args) != 1: - parser.error("Missing required PATTERN argument.") + sys.stderr.write(usage + "\n") + sys.stderr.write("Exactly one PATTERN argument required.\n") + sys.stderr.flush() + sys.exit(2) + file_in = sys.stdin file_out = sys.stdout if sys.hexversion >= 0x3000000: