Skip to content

Commit

Permalink
When writing out an embedded script before running it, write it a lin…
Browse files Browse the repository at this point in the history
…e at a time to ensure line endings are UNIX-style.
  • Loading branch information
gregneagle committed Jan 26, 2016
1 parent a885e52 commit 39cf5e8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion code/client/munkilib/munkicommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2617,7 +2617,9 @@ def writefile(stringdata, path):
Returns the path on success, empty string on failure.'''
try:
fileobject = open(path, mode='w', buffering=1)
print >> fileobject, stringdata.encode('UTF-8')
# write line-by-line to ensure proper UNIX line-endings
for line in stringdata.splitlines():
print >> fileobject, line.encode('UTF-8')
fileobject.close()
return path
except (OSError, IOError):
Expand Down

0 comments on commit 39cf5e8

Please sign in to comment.