12

I'm installing TCE and see double slashes ( // ) in the installation path. Why they are there?

 100% - /usr/local/games/enemy-territory//tcetest/ReadMe.rtf
 100% - /usr/local/games/enemy-territory//tcetest/changelog.rtf
 100% - /usr/local/games/enemy-territory//tcetest/ui.mp.i386.so
 100% - /usr/local/games/enemy-territory//tcetest/qagame.mp.i386.so
 100% - /usr/local/games/enemy-territory//tcetest/pak3.pk3
 100% - /usr/local/games/enemy-territory//tcetest/pak2.pk3

3 Answers 3

14

This happens very often and it's harmless. Double slash is interpreted like simple slash.

(see man path_resolution to understand the path resolution process)

4
  • Can you post any article where can i check it?
    – kravemir
    Jul 23, 2011 at 11:47
  • I've edited my post. The issue with double slash is not explicitly mentioned in the man page though, but you can deduce the answer. Jul 23, 2011 at 11:54
  • 3
    So still, the actual question left: why are they there? :)
    – slhck
    Jul 23, 2011 at 12:38
  • simple: programming. It is better to have it than not to and you always run it through some sort of "path.normalize()" in lang/tool of your choice. :)
    – bgs
    May 16, 2013 at 18:01
15

It's simply the result of concatenating paths as ordinary text strings.

For example, if you specify the destination directory including the ending slash...

make DESTDIR=/usr/local/games/enemy-territory/ install

...and the installer uses it like this:

$(DESTDIR)/tcetest/pak3.pk3

When the line above gets expanded, $(DESTDIR) simply will be replaced with the exact contents of the variable, resulting in:

/usr/local/games/enemy-territory//tcetest/pak3.pk3

As Stéphane mentioned in their answer, having two slashes in a path is entirely harmless, which is why most install scripts don't bother with removing them.

0

This happens when, say, a variable containing a directory/path name ends with a / then another / is appended to it without checking if the variable already ends with a /, like for example:

# say pathvariable is "/usr/bin/"
"$pathvariable/apt" # this will result in "/usr/bin//apt"

It's completely harmless, since consecutive / in file/dir names are treated as a single / on pretty much all Unix systems, including Linux. Also in 99% of cases, "directory/" is the same as "directory" (with no slash at the end) ...notable exception is rsync which can be pretty finicky about it =)

1
  • Oh and also if you have a symlink pointing to a directory, a process that can read either will see "symlink" as the link itself, and "symlink/" as the directory pointed to by "symlink". Try it with 'ls' and see the difference.
    – delt
    Feb 28 at 17:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .