Bug #32461
closedsave_to_file() in templates cuts off last end of line
Description
I have noticed when I have two save_to_file() calls right after each other that save_to_file is cutting off the last end of line.
Example:
<%= save_to_file('/tmp/first_file', snippet('first_template')) %>
<%= save_to_file('/tmp/second_file', snippet('second_template')) %>
If there is not an extra empty line in the snippet passed to save_to_file, then you get something generated like this:
cat << EOF > /tmp/first_file
This is my first file
This is the last lineEOF
And if you have two calls to save_to_file right after each other, they will get put into the same file, because the EOF from the first file is not on a line by itself and you get something like this.
cat << EOF > /tmp/first_file
This is my first file
This is the last lineEOF
cat << EOF > /tmp/second_file
This is my second file
This is the last lineEOF
And the CONTENT of the generate file contains something like this due to the end of line being cutoff.
This is my first file
This is the last lineEOF
cat << EOF > /tmp/second_file
This is my second file
This is the last line
There is probably an extra trim or something being done to the snippet data being sent to save_to_file.
If I add an extra blank line onto all the snippets used with save_to_file then the EOF is alone on the last line as required.
Updated by The Foreman Bot over 3 years ago
- Status changed from New to Ready For Testing
- Assignee set to Lukas Zapletal
- Pull request https://github.com/theforeman/foreman/pull/8488 added
Updated by Lukas Zapletal about 3 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset foreman|638c4be8fa43e5277edd86e7c8002a3b100ba526.
Updated by The Foreman Bot almost 3 years ago
- Pull request https://github.com/theforeman/foreman/pull/8976 added
Updated by Amit Upadhye almost 3 years ago
- Fixed in Releases 3.1.0 added
- Fixed in Releases deleted (
3.1.1, 3.2.0)