From 98be6a328b44f2f4e99c349228f9ae469df981f3 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Mon, 1 Oct 2012 08:30:53 +0200 Subject: [PATCH] Use a regexp to filter out arguments instead pipes.quote is a bit overzealous for what we want to do, quoting ; and other characters that you most likely want to use in your shell invocations. The regexp is the best I could come up with to be able to only replace the parts of the arguments that shouldn't be executed. --- command | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/command b/command index 61d78ec5632..1b11257de20 100755 --- a/command +++ b/command @@ -22,8 +22,8 @@ import subprocess import sys import datetime import traceback +import re import shlex -import pipes import os DOCUMENTATION = ''' @@ -131,7 +131,6 @@ class CommandModule(AnsibleModule): def _load_params(self): ''' read the input and return a dictionary and the arguments string ''' args = MODULE_ARGS - items = shlex.split(args) params = {} params['chdir'] = None params['shell'] = False @@ -139,14 +138,13 @@ class CommandModule(AnsibleModule): args = args.replace("#USE_SHELL", "") params['shell'] = True - check_args = shlex.split(args) - l_args = [] - for x in check_args: - if x.startswith("creates="): + r = re.compile(r'(^|\s)(creates|removes|chdir)=(?P[\'"])?(.*?)(?(quote)(?