News for hackers. Stuff that matters.
Re:The tale of aux.c by TorKlingberg on Tuesday September 26, 2017 @04:48AM (#15337159)
If we're going to criticise Unix file naming, I'd rather talk about how file names with spaces in them break things, or how hard it is do delete a file named "-".
Re:The tale of aux.c by zanchey on Tuesday September 26, 2017 @04:59AM (#15337200)
There's something in my environment that keeps creating a file called "-" in my home directory, and it's driving me crazy.
Re:The tale of aux.c by jovial_cavalier on Tuesday September 26, 2017 @05:36AM (#15337310)
By convention, when a unix program is passed "--" it means there are no more flags being passed. Try the following:

$ rm -- -

Re:The tale of aux.c by ConfucianNardin on Tuesday September 26, 2017 @06:33AM (#15337515)
This will not work with all rm implementations, in which case you can fall back to: rm ./-
Re:The tale of aux.c by zanchey on Tuesday September 26, 2017 @09:09AM (#15338264)
Oh, I can remove it... And a few hours or days later it's back!
Re:The tale of aux.c by jovial_cavalier on Tuesday September 26, 2017 @10:06AM (#15338739)
Okay, you're gonna want to type $sudo crontab -e...
Re:The tale of aux.c by codedokode on Tuesday September 26, 2017 @12:20PM (#15340076)
It is better to write EDITOR=nano sudo crontab ... otherwise instead of edititng the crontab you will be solving the problem of exiting vi.
Re:The tale of aux.c by zanchey on Wednesday September 27, 2017 @12:47AM (#15345002)
All the interest encouraged me to dig in and find it, and it turned out to be in one of zsh's many startup scripts.
Re:The tale of aux.c by RHSeeger on Tuesday September 26, 2017 @09:11AM (#15338283)
Open the parent directory with emacs and you can use it to delete the rogue directory/file. Admittedly, there's easier ways for a "-" named file, but its a good solution to know since you can use it to delete even the most difficult filenames.
Re:The tale of aux.c by jsymolon on Tuesday September 26, 2017 @06:37AM (#15337527)
list the file showing inode number, rm by that particular inode.
Re:The tale of aux.c by YSFEJ4SWJUVU6 on Tuesday September 26, 2017 @10:48AM (#15339122)
While GNU's not unix... afaik GNU coreutils' rm has done exactly what you expect it to when given a single dash as an argument for who knows how long.

The problem is names that could be interpreted like options, like '-f' or '--help'.

Re:The tale of aux.c by mort96 on Tuesday September 26, 2017 @04:21PM (#15342184)
Interestingly, when the shell expands * , it won't do anything to make sure files starting with - are handled properly.

This means, if you're in a directory with the files a, b, -rf, and the directories foo/ and bar/, running "rm * " will not delete all the files and keep all the directories; instead it will be turned into "rm a b bar foo -rf", meaning it will delete all the files and directories except for the file -rf.

Re:The tale of aux.c by xelxebar on Wednesday September 27, 2017 @01:43AM (#15345195)
I've definitely run into this on bash and zsh (iirc). I'm curious if this glob expansion behaviour is set in posix somewhere.
Re:The tale of aux.c by jlgaddis on Tuesday September 26, 2017 @06:43AM (#15337551)

  rm -- -
[dead]
Re:The tale of aux.c by ComputerGuru on Tuesday September 26, 2017 @07:39AM (#15337772)
> I wonder how you fare with using more complex software, like a web browser...

That snark isn’t necessary. It’s easier to use a web browser than to delete a file called - from the terminal. Or haven’t you used a non-GUI system before?

Re:The tale of aux.c by exprA on Tuesday September 26, 2017 @07:52AM (#15337824)
I don't agree with that at all; a web browser has easily a more complex user interface than a single-purpose command-line tool like “rm” – and that is even before we open any document at all, with all their conventions we have to learn before we can effectively navigate them.

Everything has a learning curve, of course, but are you sure you're just not much more familiar with one of these two?

(edit: just to clarify, what do you expect a decent rm to do when given a single argument of “-”? While there may still be systems where that does not do what you'd expect it to do – it's no different to existing obsolete versions of browsers that do nothing at all when you type in something other than a valid URL in the address bar – and are thus considerably harder to use for some not familiar with the technology. The harder corner case would be to try and remove a file with name that can be confused for a valid flag – like '-i' – but even then, that's about the only corner case for the tool, and not a steep step to learn. Any recent coreutils rm will even suggest a valid command to remove files that look like options, but are not actually valid options, so some thought has been given to discoverability as well.)