[NOT A] Re: Bug in 'ls'

David T-G <[email protected]>
Newsgroups gmane.comp.gnu.fileutils.bugs
Message-ID <[email protected]>
Todd --

...and then Todd Geders said...
% 
% If you have a filename beginning with a "dash" such as '-test.png' and you

If you have a filename beginning with a "dash" then you have to work
around it, just like you have to work around an embedded space (try

  cd /path/to/scratch/dir
  touch "this is a test"
  ls *test

and see) or any other "special" character.


% attempt to 'ls *.png' you get the following error:
% 
% $ ls *.png
% ls: invalid option -- e
% Try `ls --help' for more information.
% 
% $ ls | grep png
% -test.png

That will do it.  When you specify "*.png" your shell expands that to

  -test.png

(and would tack any other files on there if they were present).  What ls
sees is

  ls -test.png

which, of course, is the 'ls' command with the option flag '-t' and
the argument to that 'est.png' -- and the --help output clearly says

  -t                         sort by modification time

without allowing for any other arguments.


% 
% This is with GNU fileuitls version 4.1.11 on a GNU/Linux machine running
% Gentoo Linux 1.2 with gcc 2.95.3.  Have not been able to test on other
% distribution.  AFAIK, the only forbidden characters are / and NULL, so I

Well, not so much 'forbidden', but certainly less than wise.


% believe it is a bug.

Nope.  An old trick on new users, in fact :-)  Look for '--' in the docs.
For some fun, try

  cd /
  touch ./-rR
  ls *

and figure out why your reverse-sorted listing goes on and on and on ;-)

% 
% ~Todd Geders


HTH & HAND

:-D
-- 
David T-G                      * There is too much animal courage in 
(play) [email protected] * society and not sufficient moral courage.
(work) [email protected]  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/      Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

_______________________________________________
Bug-fileutils mailing list
[email protected]
http://mail.gnu.org/mailman/listinfo/bug-fileutils
signature.asc (application/pgp-signature, 187 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE+OdaTGb7uCXufRwARAkwNAJwNN53EyajSV/P+dFs9wUtyztAnvQCg3B1a
dA8+gf5G5jkV+6ViXjO1bgc=
=rI/X
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.