Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On my Linux machine some of the environment variables contain lists of directories. The directories are separated by :. But sometimes they are separated by ::. Is it just a mistake that should be treated as : or it means that and empty string is one of the directories (that probably should be interpreted as the current directory).

Most of the directories specified in the environment variables have this format:

/aaa/bbb/ccc

However, some of them have this format:

/aaa/bbb//ccc

Note double slash between bbb and ccc. Is it just a mistake that is interpreted as a single slash or it has a special meaning?

share|improve this question
add comment

2 Answers

The double-colon (::) does indeed mean the current directory. The Bash manual describes PATH as:

A colon-separated list of directories in which the shell looks for commands. A zero-length (null) directory name in the value of PATH indicates the current directory. A null directory name may appear as two adjacent colons, or as an initial or trailing colon.

But personally, I think it's better to explicitly specify the current directory (e.g., /foo/bar:.) for clarity.

As for the slashes, any number of adjacent slashes is treated as a single slash.

share|improve this answer
add comment

multiple '/' separators are ignored:

$ cd .////somedir

is equivalent to

$ cd somedir

As for the extra separators in your PATH, a little experimentation suggests that they are also ignored.

At least, this:

/home/jon.kiparsky:2040 $ echo $PATH
/home/jon.kiparsky/bin::::::/home/jon.kiparsky/bin::/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

did not break my path! :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.