How I broke ls and rm
This update is a bit of a question too, so answers on the back of a postcard....
earlier today, I was reviewing the output of a script at work that checks database backups, and warns if the md5sum of the database doesn't differ from the previous days backup. I'd got a warning that it basically hadnt found any new backups from last nights backup which worried me some what. In the directory holding the md5sums, I ran ls. Sure enough, a list of md5sums for today, yesterday and historically were listed. I decided to try and select just todays files
>ls *.today
ls: invalid option -- .
Try `ls --help' for more information.
Strange... all I'm doing is a wild card search. Changing to its parent directory, running a search worked fine with the wildcard. Sure enough, results returned. It was then that I noticed an interesting file name. rather than showing the name of a database, it was showing as "-.today"
It would appear that somehow ls was interpreting that file name as a parameter to ls, rather than a file, and because it wasn't a valid parameter, it was erroring. Similar problems happened when trying to remove the file from within its directory, but if specifying a relative or absolute path, rm behaved.
So my question is, why doe linux commands treat filies with a name starting "-." as a paramater?