Why does `//` only display for first level directories? [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
-2
down vote

favorite













This question already has an answer here:



  • What is the double slash (//) directory?

    1 answer



For the root directory a // will display in the prompt:



───────────────────────────────────────────────────────────────────────────────
rick@alien:~$ cd /
───────────────────────────────────────────────────────────────────────────────
rick@alien:/$ cd //
───────────────────────────────────────────────────────────────────────────────
rick@alien://$ cd ///
───────────────────────────────────────────────────────────────────────────────
rick@alien:/$


You can change to // directory. But when you change to /// directory it takes you back to /.



Sub-directories don't display the same way though:



───────────────────────────────────────────────────────────────────────────────
rick@alien:~$ cd /usr
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr$ cd /usr//src
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr/src$
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr/src$ cd //usr
───────────────────────────────────────────────────────────────────────────────
rick@alien://usr$
───────────────────────────────────────────────────────────────────────────────
rick@alien://usr$ cd ///usr
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr$


As you see // is automatically converted to a single / in sub-directories. However the rule doesn't apply to first level directories.



Why is // displayed for top level directories but not sub-directories?










share|improve this question















marked as duplicate by muru command-line
Users with the  command-line badge can single-handedly close command-line questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Feb 15 at 5:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • It's come up a few times over on U&L e.g. Why can I cd to // but not /// or //// or ///// or …
    – steeldriver
    Feb 15 at 1:51










  • @steeldriver Weird I got 5 points from U&L today on a closed question and was thinking I should be spending more time over there. Are you hinting these types of questions are best posted there instead of AU?
    – WinEunuuchs2Unix
    Feb 15 at 1:56










  • IMHO it's a valid question here (although arguably more about POSIX than Ubuntu) - the U&L regulars may be better at the intricacies of these things
    – steeldriver
    Feb 15 at 2:26










  • Incidentally, Zsh does not display the two slashes after cd //, neither in the prompt nor in pwd.
    – fkraiem
    Feb 15 at 6:06















up vote
-2
down vote

favorite













This question already has an answer here:



  • What is the double slash (//) directory?

    1 answer



For the root directory a // will display in the prompt:



───────────────────────────────────────────────────────────────────────────────
rick@alien:~$ cd /
───────────────────────────────────────────────────────────────────────────────
rick@alien:/$ cd //
───────────────────────────────────────────────────────────────────────────────
rick@alien://$ cd ///
───────────────────────────────────────────────────────────────────────────────
rick@alien:/$


You can change to // directory. But when you change to /// directory it takes you back to /.



Sub-directories don't display the same way though:



───────────────────────────────────────────────────────────────────────────────
rick@alien:~$ cd /usr
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr$ cd /usr//src
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr/src$
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr/src$ cd //usr
───────────────────────────────────────────────────────────────────────────────
rick@alien://usr$
───────────────────────────────────────────────────────────────────────────────
rick@alien://usr$ cd ///usr
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr$


As you see // is automatically converted to a single / in sub-directories. However the rule doesn't apply to first level directories.



Why is // displayed for top level directories but not sub-directories?










share|improve this question















marked as duplicate by muru command-line
Users with the  command-line badge can single-handedly close command-line questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Feb 15 at 5:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • It's come up a few times over on U&L e.g. Why can I cd to // but not /// or //// or ///// or …
    – steeldriver
    Feb 15 at 1:51










  • @steeldriver Weird I got 5 points from U&L today on a closed question and was thinking I should be spending more time over there. Are you hinting these types of questions are best posted there instead of AU?
    – WinEunuuchs2Unix
    Feb 15 at 1:56










  • IMHO it's a valid question here (although arguably more about POSIX than Ubuntu) - the U&L regulars may be better at the intricacies of these things
    – steeldriver
    Feb 15 at 2:26










  • Incidentally, Zsh does not display the two slashes after cd //, neither in the prompt nor in pwd.
    – fkraiem
    Feb 15 at 6:06













up vote
-2
down vote

favorite









up vote
-2
down vote

favorite












This question already has an answer here:



  • What is the double slash (//) directory?

    1 answer



For the root directory a // will display in the prompt:



───────────────────────────────────────────────────────────────────────────────
rick@alien:~$ cd /
───────────────────────────────────────────────────────────────────────────────
rick@alien:/$ cd //
───────────────────────────────────────────────────────────────────────────────
rick@alien://$ cd ///
───────────────────────────────────────────────────────────────────────────────
rick@alien:/$


You can change to // directory. But when you change to /// directory it takes you back to /.



Sub-directories don't display the same way though:



───────────────────────────────────────────────────────────────────────────────
rick@alien:~$ cd /usr
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr$ cd /usr//src
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr/src$
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr/src$ cd //usr
───────────────────────────────────────────────────────────────────────────────
rick@alien://usr$
───────────────────────────────────────────────────────────────────────────────
rick@alien://usr$ cd ///usr
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr$


As you see // is automatically converted to a single / in sub-directories. However the rule doesn't apply to first level directories.



Why is // displayed for top level directories but not sub-directories?










share|improve this question
















This question already has an answer here:



  • What is the double slash (//) directory?

    1 answer



For the root directory a // will display in the prompt:



───────────────────────────────────────────────────────────────────────────────
rick@alien:~$ cd /
───────────────────────────────────────────────────────────────────────────────
rick@alien:/$ cd //
───────────────────────────────────────────────────────────────────────────────
rick@alien://$ cd ///
───────────────────────────────────────────────────────────────────────────────
rick@alien:/$


You can change to // directory. But when you change to /// directory it takes you back to /.



Sub-directories don't display the same way though:



───────────────────────────────────────────────────────────────────────────────
rick@alien:~$ cd /usr
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr$ cd /usr//src
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr/src$
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr/src$ cd //usr
───────────────────────────────────────────────────────────────────────────────
rick@alien://usr$
───────────────────────────────────────────────────────────────────────────────
rick@alien://usr$ cd ///usr
───────────────────────────────────────────────────────────────────────────────
rick@alien:/usr$


As you see // is automatically converted to a single / in sub-directories. However the rule doesn't apply to first level directories.



Why is // displayed for top level directories but not sub-directories?





This question already has an answer here:



  • What is the double slash (//) directory?

    1 answer







command-line cd-command






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 20 at 13:04









pomsky

23.5k773100




23.5k773100










asked Feb 15 at 1:45









WinEunuuchs2Unix

36.4k760138




36.4k760138




marked as duplicate by muru command-line
Users with the  command-line badge can single-handedly close command-line questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Feb 15 at 5:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by muru command-line
Users with the  command-line badge can single-handedly close command-line questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Feb 15 at 5:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • It's come up a few times over on U&L e.g. Why can I cd to // but not /// or //// or ///// or …
    – steeldriver
    Feb 15 at 1:51










  • @steeldriver Weird I got 5 points from U&L today on a closed question and was thinking I should be spending more time over there. Are you hinting these types of questions are best posted there instead of AU?
    – WinEunuuchs2Unix
    Feb 15 at 1:56










  • IMHO it's a valid question here (although arguably more about POSIX than Ubuntu) - the U&L regulars may be better at the intricacies of these things
    – steeldriver
    Feb 15 at 2:26










  • Incidentally, Zsh does not display the two slashes after cd //, neither in the prompt nor in pwd.
    – fkraiem
    Feb 15 at 6:06

















  • It's come up a few times over on U&L e.g. Why can I cd to // but not /// or //// or ///// or …
    – steeldriver
    Feb 15 at 1:51










  • @steeldriver Weird I got 5 points from U&L today on a closed question and was thinking I should be spending more time over there. Are you hinting these types of questions are best posted there instead of AU?
    – WinEunuuchs2Unix
    Feb 15 at 1:56










  • IMHO it's a valid question here (although arguably more about POSIX than Ubuntu) - the U&L regulars may be better at the intricacies of these things
    – steeldriver
    Feb 15 at 2:26










  • Incidentally, Zsh does not display the two slashes after cd //, neither in the prompt nor in pwd.
    – fkraiem
    Feb 15 at 6:06
















It's come up a few times over on U&L e.g. Why can I cd to // but not /// or //// or ///// or …
– steeldriver
Feb 15 at 1:51




It's come up a few times over on U&L e.g. Why can I cd to // but not /// or //// or ///// or …
– steeldriver
Feb 15 at 1:51












@steeldriver Weird I got 5 points from U&L today on a closed question and was thinking I should be spending more time over there. Are you hinting these types of questions are best posted there instead of AU?
– WinEunuuchs2Unix
Feb 15 at 1:56




@steeldriver Weird I got 5 points from U&L today on a closed question and was thinking I should be spending more time over there. Are you hinting these types of questions are best posted there instead of AU?
– WinEunuuchs2Unix
Feb 15 at 1:56












IMHO it's a valid question here (although arguably more about POSIX than Ubuntu) - the U&L regulars may be better at the intricacies of these things
– steeldriver
Feb 15 at 2:26




IMHO it's a valid question here (although arguably more about POSIX than Ubuntu) - the U&L regulars may be better at the intricacies of these things
– steeldriver
Feb 15 at 2:26












Incidentally, Zsh does not display the two slashes after cd //, neither in the prompt nor in pwd.
– fkraiem
Feb 15 at 6:06





Incidentally, Zsh does not display the two slashes after cd //, neither in the prompt nor in pwd.
– fkraiem
Feb 15 at 6:06











1 Answer
1






active

oldest

votes

















up vote
3
down vote













A second slash has no meaning and the proper behaviour is for the system to treat it as if it were a single slash.



Your shell is normalising the path so that it is shown without the additional slash in all cases except for one: when the path begins with just two slashes. The shell is preserving the second slash in this case according to POSIX standards which allow paths beginning with two slashes to have a special meaning defined by the context. In this context, however, there is no special meaning and it ends up being ignored even though the shell is preserving it.






share|improve this answer


















  • 2




    POSIX requires that repeated slashes be treated as a single slash, except for the case of exactly two slashes at the start of a path (//foo as opposed to ///foo or /foo//bar), where the leading // is left the system to interpret specially if needed (network shares on Windows, nodes on QNX, etc.).
    – muru
    Feb 15 at 5:46











  • Thanks for this information, I added to the answer and made it community wiki.
    – thomasrutter
    Feb 15 at 11:19

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote













A second slash has no meaning and the proper behaviour is for the system to treat it as if it were a single slash.



Your shell is normalising the path so that it is shown without the additional slash in all cases except for one: when the path begins with just two slashes. The shell is preserving the second slash in this case according to POSIX standards which allow paths beginning with two slashes to have a special meaning defined by the context. In this context, however, there is no special meaning and it ends up being ignored even though the shell is preserving it.






share|improve this answer


















  • 2




    POSIX requires that repeated slashes be treated as a single slash, except for the case of exactly two slashes at the start of a path (//foo as opposed to ///foo or /foo//bar), where the leading // is left the system to interpret specially if needed (network shares on Windows, nodes on QNX, etc.).
    – muru
    Feb 15 at 5:46











  • Thanks for this information, I added to the answer and made it community wiki.
    – thomasrutter
    Feb 15 at 11:19














up vote
3
down vote













A second slash has no meaning and the proper behaviour is for the system to treat it as if it were a single slash.



Your shell is normalising the path so that it is shown without the additional slash in all cases except for one: when the path begins with just two slashes. The shell is preserving the second slash in this case according to POSIX standards which allow paths beginning with two slashes to have a special meaning defined by the context. In this context, however, there is no special meaning and it ends up being ignored even though the shell is preserving it.






share|improve this answer


















  • 2




    POSIX requires that repeated slashes be treated as a single slash, except for the case of exactly two slashes at the start of a path (//foo as opposed to ///foo or /foo//bar), where the leading // is left the system to interpret specially if needed (network shares on Windows, nodes on QNX, etc.).
    – muru
    Feb 15 at 5:46











  • Thanks for this information, I added to the answer and made it community wiki.
    – thomasrutter
    Feb 15 at 11:19












up vote
3
down vote










up vote
3
down vote









A second slash has no meaning and the proper behaviour is for the system to treat it as if it were a single slash.



Your shell is normalising the path so that it is shown without the additional slash in all cases except for one: when the path begins with just two slashes. The shell is preserving the second slash in this case according to POSIX standards which allow paths beginning with two slashes to have a special meaning defined by the context. In this context, however, there is no special meaning and it ends up being ignored even though the shell is preserving it.






share|improve this answer














A second slash has no meaning and the proper behaviour is for the system to treat it as if it were a single slash.



Your shell is normalising the path so that it is shown without the additional slash in all cases except for one: when the path begins with just two slashes. The shell is preserving the second slash in this case according to POSIX standards which allow paths beginning with two slashes to have a special meaning defined by the context. In this context, however, there is no special meaning and it ends up being ignored even though the shell is preserving it.







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 15 at 11:18


























community wiki





2 revs
thomasrutter








  • 2




    POSIX requires that repeated slashes be treated as a single slash, except for the case of exactly two slashes at the start of a path (//foo as opposed to ///foo or /foo//bar), where the leading // is left the system to interpret specially if needed (network shares on Windows, nodes on QNX, etc.).
    – muru
    Feb 15 at 5:46











  • Thanks for this information, I added to the answer and made it community wiki.
    – thomasrutter
    Feb 15 at 11:19












  • 2




    POSIX requires that repeated slashes be treated as a single slash, except for the case of exactly two slashes at the start of a path (//foo as opposed to ///foo or /foo//bar), where the leading // is left the system to interpret specially if needed (network shares on Windows, nodes on QNX, etc.).
    – muru
    Feb 15 at 5:46











  • Thanks for this information, I added to the answer and made it community wiki.
    – thomasrutter
    Feb 15 at 11:19







2




2




POSIX requires that repeated slashes be treated as a single slash, except for the case of exactly two slashes at the start of a path (//foo as opposed to ///foo or /foo//bar), where the leading // is left the system to interpret specially if needed (network shares on Windows, nodes on QNX, etc.).
– muru
Feb 15 at 5:46





POSIX requires that repeated slashes be treated as a single slash, except for the case of exactly two slashes at the start of a path (//foo as opposed to ///foo or /foo//bar), where the leading // is left the system to interpret specially if needed (network shares on Windows, nodes on QNX, etc.).
– muru
Feb 15 at 5:46













Thanks for this information, I added to the answer and made it community wiki.
– thomasrutter
Feb 15 at 11:19




Thanks for this information, I added to the answer and made it community wiki.
– thomasrutter
Feb 15 at 11:19


Popular posts from this blog

GRUB: Fatal! inconsistent data read from (0x84) 0+xxxxxx

`kcmshell` modules relation with `/usr/share/applications`

How to enroll fingerprints to Ubuntu 17.10 with VFS491