Hello everybody,
I came across to this today. It seems that Pathname is not able to parse
Windows paths with backslashes when running on Unix environment.
# on Unix
irb(main):016:0> Pathname("c:\\hello\\world\\file.exe").basename
=> #<Pathname:c:\hello\world\file.exe>
# on Windows
irb(main):016:0> Pathname("c:\\hello\\world\\file.exe").basename
=> #<Pathname:file.exe>
I know that a solution on Unix is to use #gsub method to replace
backslashes with forward slashes:
irb(main):019:0> Pathname("c:\\hello\\world\\file.exe".gsub(/\\/,
'/')).basename
=> #<Pathname:file.exe>
However, Unix paths are parsed correctly on Windows environment:
irb(main):016:0> Pathname("/hello/world/file.exe").basename
=> #<Pathname:file.exe>
...but Windows paths don't work well on Unix.
shouldn't Pathname take care of it instead of me manipulating the path?
I personally would consider this an unexpected behavior.
Any thoughts?
Thank you,
*Fabio Pitino*