Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 100509 - Warning about PATH and leading/trailing ':'.
Summary: Warning about PATH and leading/trailing ':'.
Status: RESOLVED FIXED
Alias: None
Product: [OLD] Docs-user
Classification: Unclassified
Component: Handbook (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Sven Vermeulen (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-27 12:35 UTC by Tres 'RiverRat' Melton
Modified: 2005-08-01 05:07 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tres 'RiverRat' Melton 2005-07-27 12:35:46 UTC
I have discovered that a leading or trailing space in bash's PATH variable has
the same effect as placing a '.' in there.  I'm not a Linux newbie but I just
found this out by talking to some people in #gentoo.  I've read a number of
books on the issue and can't ever recall reading that.  I suggest that a comment
be added to:

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=5

In section 5a, Envirnment Variables, under the PATH portion.  I am also going to
try and get a comment added to /etc/bash/bashrc and /etc/skel/.bashrc as well.
Comment 1 SpanKY gentoo-dev 2005-07-27 13:55:58 UTC
i dont really want to add this to bashrc but the handbook sounds good

this isnt just PATH, just about all variables that represent paths and are
delimited have the implied meaning NULL == $PWD

so LD_LIBRARY_PATH="/blah/blah:" means search /blah/blah and $PWD
Comment 2 Sven Vermeulen (RETIRED) gentoo-dev 2005-07-30 08:11:38 UTC
we're talking here about trailing space, not trailing delimiter. I just tried,
and having "export PATH="${PATH} "" or " ${PATH}" does not imply ${PWD}.

I'm marking this as WONTFIX, there is no reason to describe how all this works
in the Gentoo Handbook as it's more bash general and doesn't affect anything
written in the chapter.
Comment 3 SpanKY gentoo-dev 2005-07-30 18:27:33 UTC
i think he just typoed in the original comment considering his summary says
leading/trailing :
Comment 4 Tres 'RiverRat' Melton 2005-08-01 00:20:04 UTC
I just noticed the deatils section of my original and the comments that follow
and I want to apologize for saying space.  I meant to say colon.  I really don't
remember having seen any warnings about this in my readings but the man pages
does say:  

" 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."

I'm going to reopen this so that you see this last comment but if you want to
close it then I'm not going to object.  *I* won't make that mistake again. 
There were quite a few people in #gentoo that were surprised by this behavior,
including some of the ops.  I don't see how a single line about it can be bad
and might cause users to be more conscious of their PATH settings.  I suggest: 
"An empty string, leading/trailing colon, or pair of colons implies the current
directory."
Comment 5 Sven Vermeulen (RETIRED) gentoo-dev 2005-08-01 05:04:01 UTC
Because people asked so nicely on irc :p
Comment 6 Sven Vermeulen (RETIRED) gentoo-dev 2005-08-01 05:07:33 UTC
I've integrated it in an example further down the chapter. I don't think it was
worth adding a new paragraph for this because the subject of the chapter is not
to talk about the PATH variable or how it is treated by bash, but how Portage
works with the variables.

So I made a compromise and had an example add the current working directory.