What is the meaning of // in bash?

I noticed that in bash / zsh, if I am cd // , it puts me in a directory called "//" - pwd shows this, as well as my invitation.

If I use more than two slashes like cd /// etc., it just puts me in /.

Is there a value for the // directory in bash?

+6
source share
1 answer

The POSIX standard states that // can be interpreted in a certain way using a compatible operating system, and /// equivalent to / :

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_12

If the path name begins with two consecutive characters, the first component following the leading characters can be interpreted according to the implementation, although more than two leading characters should be considered as one character.

For this reason, bash keeps // unchanged only if the underlying OS implements this particular value.

+10
source

Source: https://habr.com/ru/post/976985/


All Articles