Merge branch 'issue_5679_lineinfile' into fix_lineinfile_newlines

reviewable/pr18780/r1
James Cammarata 11 years ago
commit 4adf2c4dfd

@ -19,6 +19,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
import pipes
import re import re
import os import os
import tempfile import tempfile
@ -359,9 +360,14 @@ def main():
if ins_bef is None and ins_aft is None: if ins_bef is None and ins_aft is None:
ins_aft = 'EOF' ins_aft = 'EOF'
# Replace the newline character with an actual newline. Don't replace # Replace escape sequences like '\n' while being sure
# escaped \\n, hence sub and not str.replace. # not to replace octal escape sequences (\ooo) since they
line = re.sub(r'\n', os.linesep, params['line']) # match the backref syntax
if backrefs:
line = re.sub(r'(\\[0-9]{1,3})', r'\\\1', params['line'])
else:
line = params['line']
line = module.safe_eval(pipes.quote(line))
present(module, dest, params['regexp'], line, present(module, dest, params['regexp'], line,
ins_aft, ins_bef, create, backup, backrefs) ins_aft, ins_bef, create, backup, backrefs)

Loading…
Cancel
Save