Shriramana, On Saturday 25 February 2006 23:54, Shriramana Sharma wrote:
...
I have not seen ls commands in other directories automatically listing subdirectory contents unless specifically told to do so. Why does /usr/bin alone behave this way?
Surely you don't believe there's some kind of special case in ls or some other code for /usr/bin? In fact, there is not. You have to understand how things work (shocking, isn't it?) in order to predict their behavior. When unquoted and unescaped wild-cards (*, ? and [...]) are present in a command submitted to the shell, the first thing that happens is that those wild cards are expanded. (Options determine whether or not it's an error for nothing to match one or more of the patterns given.) Once this expansion has produced the final argument list, the command is invoked, passing those arguments to it. Now in the case of ls (and when the "-d" option is not given), any argument that names a directory is taken as a request to list that directories _contents_, not the directory itself. The -d option tells ls to list any directories given as arguments instead of their contents. There. Now you have enough information to explain what you're seeing. No magic, no special cases for /usr/bin and something that's explained in countless Web pages and books... Randall Schulz