diff options
Diffstat (limited to 'setuptools/command/alias.py')
-rwxr-xr-x | setuptools/command/alias.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/setuptools/command/alias.py b/setuptools/command/alias.py index b184589f..f5368b29 100755 --- a/setuptools/command/alias.py +++ b/setuptools/command/alias.py @@ -5,6 +5,15 @@ from distutils import log from distutils.errors import * from setuptools.command.setopt import edit_config, option_base, config_file +def shquote(arg): + """Quote an argument for later parsing by shlex.split()""" + for c in '"', "'", "\\", "#": + if c in arg: return repr(arg) + if arg.split()<>[arg]: + return repr(arg) + return arg + + class alias(option_base): """Define a shortcut that invokes one or more commands""" @@ -17,13 +26,11 @@ class alias(option_base): boolean_options = option_base.boolean_options + ['remove'] - def initialize_options(self): option_base.initialize_options(self) self.args = None self.remove = None - def finalize_options(self): option_base.finalize_options(self) if self.remove and len(self.args)<>1: @@ -32,13 +39,6 @@ class alias(option_base): "using --remove" ) - - - - - - - def run(self): aliases = self.distribution.get_option_dict('aliases') @@ -61,7 +61,7 @@ class alias(option_base): return else: alias = self.args[0] - command = ' '.join(map(repr,self.args[1:])) + command = ' '.join(map(shquote,self.args[1:])) edit_config(self.filename, {'aliases': {alias:command}}, self.dry_run) |