Skip to content
This repository

some file paths break in windows (e.g cat #{_file_}) #708

Closed
banister opened this Issue · 4 comments

3 participants

John Mair Jordon Bedwell Kyrylo Silin
John Mair
Owner

e.g

[12] pry(main)> $ Pry#r

From: C:/Ruby193/lib/ruby/gems/1.9.1/gems/pry-0.9.10-x86-mingw32/lib/pry/pry_ins
Number of lines: 25
Owner: Pry
Visibility: public

def r(target=TOPLEVEL_BINDING, eval_string="")
  target = Pry.binding_for(target)
  @suppress_output = false

  loop do
    begin
      # eval_string will probably be mutated by this method
      retrieve_line(eval_string, target)
    rescue CommandError, Slop::InvalidOptionError, MethodSource::SourceNotFoundE
      output.puts "Error: #{e.message}"
    end

    begin
      break if Pry::Code.complete_expression?(eval_string)
    rescue SyntaxError => e
      output.puts "SyntaxError: #{e.message.sub(/.*syntax error, */m, '')}"
      eval_string = ""
    end
  end

  @suppress_output = true if eval_string =~ /;\Z/ || eval_string.empty?

  exec_hook :after_read, eval_string, self
  eval_string
end
[13] pry(main)> _file_
=> "C:/Ruby193/lib/ruby/gems/1.9.1/gems/pry-0.9.10-x86-mingw32/lib/pry/pry_insta
nce.rb"
[14] pry(main)> cat #{_file_}
Error: Cannot open "C:/Users/Owner/Documents/GitHub/pry-exception_explorer/C" fo
r reading.
[15] pry(main)> _file_
=> "C:/Users/Owner/Documents/GitHub/pry-exception_explorer/C"
[16] pry(main)>
Jordon Bedwell

Have cat run it through Pathname and then do Pathname#read or Pathname#binread.

Kyrylo Silin
Collaborator

@envygeeks, sounds good. Open a pull request?

Jordon Bedwell

@kyrylo I'll see if I can find time today to do it.

yui-knk referenced this issue from a commit in yui-knk/pry
yui-knk Fix some file paths break in Windows (#708). file_and_line methods in…
… lib/pry/commands/cat/file_formatter.rb split file path with ':'. So if file path is 'c:/path/to/file', this method works incorrectly. This fix replace ':' to regexp
4b284f9
Deleted user

@yui-knk has opened a PR to address this issue #1050

Deleted user ghost closed this
Deleted user Unknown referenced this issue from a commit
yui-knk Fix some file paths break in Windows (#708). file_and_line methods in…
… lib/pry/commands/cat/file_formatter.rb split file path with ':'. So if file path is 'c:/path/to/file', this method works incorrectly. This fix replace ':' to regexp
3962b46
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.