Allow gem executable to contain spaces

rbenv has a special exec function which loads the correct ruby version before executing a command.
The syntax for this is `/usr/local/rbenv/bin/rbenv exec gem ...` for example.
But previously when specifying executable='/usr/local/rbenv/bin/rbenv exec gem' this would not work because the string was treated as one executable. This PR fixes that by splitting the executable on spaces.
pull/7801/head
Koen Punt 11 years ago
parent 4be33b6a63
commit d9f9234084

@ -91,12 +91,12 @@ import re
def get_rubygems_path(module): def get_rubygems_path(module):
if module.params['executable']: if module.params['executable']:
return module.params['executable'] return module.params['executable'].split(' ')
else: else:
return module.get_bin_path('gem', True) return [ module.get_bin_path('gem', True) ]
def get_rubygems_version(module): def get_rubygems_version(module):
cmd = [ get_rubygems_path(module), '--version' ] cmd = get_rubygems_path(module) + [ '--version' ]
(rc, out, err) = module.run_command(cmd, check_rc=True) (rc, out, err) = module.run_command(cmd, check_rc=True)
match = re.match(r'^(\d+)\.(\d+)\.(\d+)', out) match = re.match(r'^(\d+)\.(\d+)\.(\d+)', out)
@ -107,7 +107,7 @@ def get_rubygems_version(module):
def get_installed_versions(module, remote=False): def get_installed_versions(module, remote=False):
cmd = [ get_rubygems_path(module) ] cmd = get_rubygems_path(module)
cmd.append('query') cmd.append('query')
if remote: if remote:
cmd.append('--remote') cmd.append('--remote')
@ -144,7 +144,7 @@ def uninstall(module):
if module.check_mode: if module.check_mode:
return return
cmd = [ get_rubygems_path(module) ] cmd = get_rubygems_path(module)
cmd.append('uninstall') cmd.append('uninstall')
if module.params['version']: if module.params['version']:
cmd.extend([ '--version', module.params['version'] ]) cmd.extend([ '--version', module.params['version'] ])
@ -165,7 +165,7 @@ def install(module):
else: else:
major = None major = None
cmd = [ get_rubygems_path(module) ] cmd = get_rubygems_path(module)
cmd.append('install') cmd.append('install')
if module.params['version']: if module.params['version']:
cmd.extend([ '--version', module.params['version'] ]) cmd.extend([ '--version', module.params['version'] ])

Loading…
Cancel
Save