3 ms·
Tell HN: cd // Is Special
Yep. That is all. I just discovered this. Almost a 20 year bash user. A typo today led me down this somewhat short rabbit hole:
[...]@MacBook-Air:~$ cd //
[...]@MacBook-Air://$ pwd
//
[...]@MacBook-Air://$ cd /
[...]@MacBook-Air:/$ cd //
[...]@MacBook-Air://$ cd ///
[...]@MacBook-Air:/$ cd ////
[...]@MacBook-Air:/$ cd //
[...]@MacBook-Air://$
I checked on a Debian box and same thing. Both cases bash is ~ v5.2 but I guess this is a long time thing. Who woulda thought?
I kinda like the double slash. Very internet-y. I wonder if that's related to why TBL included (apparently later regretting) the '//' in URLs?
- myst 2y agoDoes not work this way in Zsh. What's the purpose of that in Bash?
- wruza 2y agohttps://stackoverflow.com/questions/20690828/what-does-double-slash-in-cd-mean-in-linux https://stackoverflow.com/questions/20690828/what-does-doubl...
- keepamovin 2y agoThank you for that! This was particularly interesting: Certain versions of Unix, and early network file systems, used paths of the form //hostname/path to access 'path' on server 'hostname'. It directly ties in with the URL format: scheme://hostname/path/to/file How cool it would be if we could go: cd //google.com/search?q=quack+like+duck and we would get a directory with 1 file per result (or to be really unix like: 1 directory per result, with a set of files and directories for different aspects of the result hehehe :))
- wruza 2y agoThis is an old idea behind “everything is file” and plan9, afaik. FUSE allows this, you can easily write a “driver” that does exactly this on a mountpoint like /mnt/mywebfs/whatever.com/search?q=…. /proc (procfs) is basically this but for kernel structures.
- keepamovin 2y agoI recall somebody did this with www, I think at first using a browser extension? Webfs possibly. It is a really cool idea. I find it makes many things easy to deal with, and those that aren’t? Interesting to think about. The hierarchical abstraction of a file system is a good model from many things
- deleted 2y ago[deleted]