Re: cd //
しらいです。
In article <d01ks3$eab$1@news-wst.ocn.ad.jp>,
Tanaka-Qtaro-Yasuhiro <tanaq@ca2.so-net.ne.jp> wrote:
>田中久太郎です。
>でもなぜ bash は $PWD を // にするのだろう?
bash の source によると、「POSIX.2 says to leave a leading
`//' alone.」だそうで。POSIX にそんな仕様あったかなと思って
調べてみましたがこれのことかな?
http://www.opengroup.org/onlinepubs/009695399/utilities/cd.html
An implementation may further simplify curpath by
removing any trailing slash characters that are not
also leading slashes, replacing multiple non-leading
consecutive slashes with a single slash, and replacing
three or more leading slashes with a single slash.
If, as a result of this canonicalization, the curpath
variable is null, no further steps shall be taken.
三つ以上だと一つにしちゃうけど二つまでなら保持せよってこと
のようですが、何故なのか理由が書いてありませんね。
環境によっては「//」が特殊な仮想 directory を指すこともあ
るので、それを配慮してのことなんじゃないでしょうか。chdir(2)
が実際に「//」をどう解釈するかは bash 側では判りませんから。
--
しらい たかし
Fnews-brouse 1.9(20180406) -- by Mizuno, MWE <mwe@ccsf.jp>
GnuPG Key ID = ECC8A735
GnuPG Key fingerprint = 9BE6 B9E9 55A5 A499 CD51 946E 9BDC 7870 ECC8 A735