Skip to content

Commit

Permalink
Fix space handling for edit command
Browse files Browse the repository at this point in the history
Fix issue #623 (edit command can't handle paths with spaces in the
name).

------------------------------------------------------------------------
Description by banister:

  >> .cd /Users/john/Library/Application Support/
  >> edit hello.rb

  The editor freaks out, opening two files, one called
  `/Users/john/Library/Application` and the other called
  `Support/hello.rb`
------------------------------------------------------------------------

Use Shellwords, because it's is a jewel.

Reported-by: John Mair <jrmair@gmail.com>
Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
  • Loading branch information
kyrylo committed Jul 1, 2012
1 parent d57f229 commit a58703b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/pry/default_commands/editing.rb
@@ -1,4 +1,5 @@
require 'tempfile'
require 'shellwords'
require 'pry/default_commands/hist'

class Pry
Expand Down Expand Up @@ -141,8 +142,12 @@ def process_remote_edit
line = opts[:l].to_i if opts.present?(:line)

reload = opts.present?(:reload) || ((opts.present?(:ex) || file_name.end_with?(".rb")) && !opts.present?(:'no-reload')) && !Pry.config.disable_auto_reload
invoke_editor(file_name, line, reload)
set_file_and_dir_locals(file_name)

# Sanitize blanks.
sanitized_file_name = Shellwords.escape(file_name)

invoke_editor(sanitized_file_name, line, reload)
set_file_and_dir_locals(sanitized_file_name)

if reload
silence_warnings do
Expand Down

0 comments on commit a58703b

Please sign in to comment.