diff options
author | PJ Eby <distutils-sig@python.org> | 2005-07-08 15:49:53 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2005-07-08 15:49:53 +0000 |
commit | 1d7b59f5172a215ad9961e2eb8bbd1756b941a5f (patch) | |
tree | 17b53cc772dd05f8ef76585cfe38203721008f88 /setuptools/command/alias.py | |
parent | d399fdec29aa413761eef7a5cd6355ae6b2a96f0 (diff) | |
download | external_python_setuptools-1d7b59f5172a215ad9961e2eb8bbd1756b941a5f.tar.gz external_python_setuptools-1d7b59f5172a215ad9961e2eb8bbd1756b941a5f.tar.bz2 external_python_setuptools-1d7b59f5172a215ad9961e2eb8bbd1756b941a5f.zip |
Cleaner argument quoting in command aliases.
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041098
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) |