[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bizarre ls Behavior

On Fri, Jul 22, 2005 at 01:34:06PM -0500, Martin McCormick wrote:
| Hendrik Sattler writes:
| >Guessing: your $PATH contains "." before the "/bin"
| >Bad thing!
| >When in doubt: run /bin/ls instead of ls.
| 	Wow!  I've been doing UNIX for around 14 years and am flat
| ashamed of myself.  I have now put . at the end of the path and, of
| course it all works.  I have heard before that putting ones current
| working directory first is bad, but I never quite understood why
| because the examples I had heard were kind of a stretch in many cases
| but this one shines like a light.

Don't include '.' at all.  In the event you really want to run a
binary or script in the current directory use ./<name> instead of

Well, I guess that failed because
    1)  you 'cd' to the directory before looking at it
    2)  you had '.' (first) in $PATH
    3)  ./ls was not executable and/or readable (by you)
        (or it is dynamically linked and not usable on the running OS)

If you don't know and trust the contents of '.', be sure 1) not to put
it in $PATH and 2) look at the directory before changing to it.

Another cause for the symptoms you described is if you have execute
permission on the directory but not read permission.  That would allow
'cd' but not 'ls'.


Q:  What's the difference between a computer salesman and a used car salesman?
A:  A used car salesman knows when he's lying.
www: http://dman13.dyndns.org/~dman/            jabber: dman@dman13.dyndns.org

Attachment: signature.asc
Description: Digital signature

Reply to: