Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
13e8ef5f
Commit
13e8ef5f
authored
Sep 29, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1146 from dhozac/command-escape-args
Properly parse escaped special arguments
parents
7d86663d
9261d396
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
library/command
+6
-5
No files found.
library/command
View file @
13e8ef5f
...
...
@@ -23,6 +23,7 @@ import sys
import
datetime
import
traceback
import
shlex
import
pipes
import
os
DOCUMENTATION
=
'''
...
...
@@ -139,6 +140,7 @@ class CommandModule(AnsibleModule):
params
[
'shell'
]
=
True
check_args
=
shlex
.
split
(
args
)
l_args
=
[]
for
x
in
check_args
:
if
x
.
startswith
(
"creates="
):
# do not run the command if the line contains creates=filename
...
...
@@ -154,7 +156,6 @@ class CommandModule(AnsibleModule):
stderr
=
False
,
rc
=
0
)
args
=
args
.
replace
(
x
,
''
)
elif
x
.
startswith
(
"removes="
):
# do not run the command if the line contains removes=filename
# and the filename do not exists. This allows idempotence
...
...
@@ -169,7 +170,6 @@ class CommandModule(AnsibleModule):
stderr
=
False
,
rc
=
0
)
args
=
args
.
replace
(
x
,
''
)
elif
x
.
startswith
(
"chdir="
):
(
k
,
v
)
=
x
.
split
(
"="
,
1
)
v
=
os
.
path
.
expanduser
(
v
)
...
...
@@ -178,8 +178,9 @@ class CommandModule(AnsibleModule):
elif
v
[
0
]
!=
'/'
:
self
.
fail_json
(
msg
=
"the path for 'chdir' argument must be fully qualified"
)
params
[
'chdir'
]
=
v
args
=
args
.
replace
(
x
,
''
)
params
[
'args'
]
=
args
return
(
params
,
args
)
else
:
l_args
.
append
(
x
)
params
[
'args'
]
=
" "
.
join
([
pipes
.
quote
(
x
)
for
x
in
l_args
])
return
(
params
,
params
[
'args'
])
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment