You are currently browsing the monthly archive for October 2008.
Getting a line feed into an input on *nix is pretty easy, all you do is hit return in the middle of a quoted input:
% ruby -e 'puts ARGV.inspect' 'line one > line two' ["line one\nline two"]
On Windows, it’s more verbose. Use a caret, the MS-DOS escape character, to ignore the next line feed:
% ruby -e 'puts ARGV.inspect' 'line one^ More? More? line two' ["line one\nline two"]
Notice that pressing enter every other line is what actually puts the “\n” into the argument . Keep using carets to enter more lines.
The syntax on Windows isn’t exactly pretty, and sadly it doesn’t work with gem executables; the .bat scripts generated by rubygems re-processes inputs before calling the .rb executable and the extra lines get lost in translation. Still, it’s nice to know it’s (sort-of) possible!