hatanaka tomoyuki
hatanaka tomoyuki
気になったので、いろいろ調べてみました。 まず RDoc には、 `Dir.chdir("~/filename")` などで `~` が展開される/されない、といった記述は見当たらないですね。 [https://docs.ruby-lang.org/en/3.3/Dir.html#method-c-chdir](https://docs.ruby-lang.org/en/3.3/Dir.html#method-c-chdir) `File.expand_path("~/filename")` は、 `s_expand_path` [`v3_3_6` file.c#L4132-L4164](https://github.com/ruby/ruby/blob/v3_3_6/file.c#L4132-L4164) `rb_file_s_expand_path` [`v3_3_6` file.c#L4125-L4130](https://github.com/ruby/ruby/blob/v3_3_6/file.c#L4125-L4130) `rb_file_expand_path` [`v3_3_6` file.c#L4112-L4117](https://github.com/ruby/ruby/blob/v3_3_6/file.c#L4112-L4117) `expand_path` [`v3_3_6` file.c#L4099-L4100](https://github.com/ruby/ruby/blob/v3_3_6/file.c#L4099-L4100) `rb_file_expand_path_internal` [`v3_3_6` file.c#L3740-L4087](https://github.com/ruby/ruby/blob/v3_3_6/file.c#L3740-L4087) の流れで、最終的に `~` が展開されるようです。 WIN32...
`~` を展開する言語は、あまりないような気がします。 ``` >>> import os >>> os.chdir("~/filename") Traceback (most recent call last): File "", line 1, in os.chdir("~/filename") ~~~~~~~~^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '~/filename' >>>...
ありがとうございます。 実際に `~` というディレクトリが存在するときの例については、なくてもよいかなと思います。 `~` と `$HOME` のどちらかをわかるように記述しようとすると、相当に複雑になりそうです。 \--- それでは、上記内容で PR を作成してみます。