-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to andrew scott on 7/5/2007 8:39 AM: > Dear GNU people, > > Re: Core Utils V6.4 'ls' command
The latest stable version is 6.9; you may want to consider upgrading. > > I am in my home directory. I make a new sub-directory > called 'p001_project'. I have a file at the home > level called 'p001_data.c'. I use an ls command like > this:- > > ls -ls p001* You used a glob, which is interpreted by the shell. To see what you actually did, you can use echo: $ echo ls -ls p001* ls -ls p001_data.c p001_project Which lists the details of both p001_data.c and the p001_project directory (which I'm guessing was empty at the time you tried this?). > > and I get the file listed as expected. I then move > the file from home into the sub-directory and repeat > the ls command:- > > ls -ls p001* > > and, amazingly, the file is still listed. Note that I > have NOT used the -R switch to ls, which would then > make the command recursive. Here, you did ls -ls p001_project and since you listed the directory which contains p001_data.c, it was listed. No recursion necessary. > > If instead, I use this command:- > > ls -ls p001_data.c > > I get NO files listed. Of course - because there is no p001_data.c in the current directory. > If I then issue this command:- > > ls -lsR p001* > > then I get a heading from ls saying there is a > sub-directory present, in which the file is then > listed as expected. Yes, because now you issued the command: ls -lsR p001_project and p001_data.c happens to be encountered when recursively listing the p001_project directory. > > It seems to me me that somehow, if there is a wildcard > present (the '*' in this example) then the command > goes recursive on sub-directories without printing out > the sub-directory heading. No, actually what is happening is that the * is interpreted by the shell prior to ls ever even seeing its command line arguments. When handed a directory, ls lists the directory contents when the -d flag is not in effect. For further proof, rename the directory to not start with the same prefix as the file, and see what changes. There is no bug in ls in this regard. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGjQVs84KuGfSFAYARAmYMAKCyzf1XwTVlO6Ie/Uucj1aQBJQcYwCgovWe F66/IY2Xv0ri4F3kuviXKTY= =RfHI -----END PGP SIGNATURE----- _______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
