Skip to content

Commit

Permalink
cast before and after in sed stuff, Fix #1095
Browse files Browse the repository at this point in the history
  • Loading branch information
thatch45 committed Apr 23, 2012
1 parent 1e403ea commit 8589ff8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions salt/modules/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ def sed(path, before, after, limit='', backup='.bak', options='-r -e',
'''
# Largely inspired by Fabric's contrib.files.sed()
# XXX:dc: Do we really want to always force escaping?
#
# Mandate that before and after are strings
before = str(before)
after = str(after)
before = _sed_esc(before, escape_all)
after = _sed_esc(after, escape_all)

Expand Down
4 changes: 4 additions & 0 deletions salt/states/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,10 @@ def sed(name, before, after, limit='', backup='.bak', options='-r -e',
# sed returns no output if the edit matches anything or not so we'll have
# to look for ourselves

# Mandate that before and afetr are strings
before = str(before)
after = str(after)

# Look for the pattern before attempting the edit
if not __salt__['file.contains'](name, before, limit):
# Pattern not found; try to guess why
Expand Down

2 comments on commit 8589ff8

@laroche
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afetr -> after typo in the above change

best regards,

Florian La Roche

@thatch45
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks!

Please sign in to comment.