Nobuyoshi Nakada wrote:
If they do it, you have no way to test files start with '~'.
Good point, I hadn't thought about this borderline case. And from this case, I take that this is not a bug on FileTest
, but on #expand_path
.
I have played with a bit and it operates in an awkward way. It can expand ~/~derp_folder~/~derp
, but it cant expand ~derp
.
Or always File.exist?(path.sub(/\A~/, './~')) and so on.
It is not about what I prefer, but about what works. In my humble opinion, I think this #sub
(or some other method) will indeed have to be called, but not on FileTest
. It should be called on the first lines of #expand_path
. And this pattern will have to be refined a bit more. I tried it on some cases and it works for some, but for others it produces a path totally different. I think we will have to use #sub
passing a block to it to have more control over the pattern substitution.
What do you think? And, by the way, should we continue this conversation here or should I open a new bug reporting #expand_path
?