When I need to progmatically open in emacs a file that has a space in its name, how can I do that? I've tried these commands from a Ruby script, inside backquotes or popen():emacs foo baror emacs foo\ baropens two files each named foo and bar, but I want to open a file named foo bar.
Opening a file with space from Ruby
escape characters;ruby
You're having problems with quoting because you're calling popen with a commandline, which is passed to the shell.  Ruby's string parser is either eating the double quotes or eating the backslash.  You can either call popen with an array of strings, which will bypass the shell, or you can write emacs foo\\ bar which will escape the backslash that you want Ruby to leave for the shell to see.