[FIX] ensures no illegitimate cli argument is silently discarded

This avoids an insidious behavior: when copy-pasting a command from a
Microsoft document to the cmd terminal, one might not see that a hyphen ('-')
preceding an option has been converted to a dash (u'\u2012') which is then
interpreted as a normal cli argument (i.e. not an option) and thus silently
discarded.

bzr revid: jth@openerp.com-20110209100735-jaschhlv3cfqjry5
This commit is contained in:
Julien Thewys 2011-02-09 11:07:35 +01:00
parent 14ebc46e3a
commit 6a11b89e17
1 changed files with 5 additions and 3 deletions

View File

@ -251,12 +251,14 @@ class configmanager(object):
self.parse_config()
def parse_config(self, args=[]):
opt = self.parser.parse_args(args)[0]
opt, args = self.parser.parse_args()
def die(cond, msg):
if cond:
print msg
sys.exit(1)
self.parser.error(msg)
# Ensures no illegitimate argument is silently discarded (avoids insidious "hyphen to dash" problem)
die(args, "unrecognized parameters were passed: '%s'" % " ".join(args))
die(bool(opt.syslog) and bool(opt.logfile),
"the syslog and logfile options are exclusive")