Permalink
Browse files

Fix shebang handling for empty files. References #2927.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3258 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 3fb5828 commit b056adf03bd8b331db80f40f484126795d5d9323 @jeremy jeremy committed Dec 9, 2005
Showing with 3 additions and 4 deletions.
  1. +3 −4 railties/lib/rails_generator/commands.rb
@@ -220,12 +220,11 @@ def file(relative_source, relative_destination, file_options = {}, &block)
if block_given?
df.write(yield(sf))
else
- line = sf.gets || ''
if file_options[:shebang]
df.puts("#!#{file_options[:shebang]}")
- df.puts(line) if line !~ /^#!/
- else
- df.puts(line)
+ if line = sf.gets
+ df.puts(line) if line !~ /^#!/
+ end
end
df.write(sf.read)
end

0 comments on commit b056adf

Please sign in to comment.