Live data from Hacker News

Ooops.

github.com

141–150 of 247 posts

Re: Ooops.

#141
I've started quoting arguments in shell scripts even when it's not technically necessary to avoid problems with spaces. I can't count how many scripts I've written/encountered that didn't work with a path containing a space (apparently much more common with OS X users than Linux users)

This wouldn't delete the correct directory, but at least it won't delete "/usr" either:

    rm -rf "/usr /lib/nvidia-current/xorg/xorg"
There are lots of other pitfalls associated with not quoting things in shell scripts, like this common one:

    if [ $foo -eq "bar" ];
will cause an error if $foo isn't set or is an empty string, while this will work correctly:

    if [ "$foo" -eq "bar" ];
Bonus that your syntax highlighter can highlight the arguments. My rule is that flags aren't quoted, but paths and other parameters are.

Re: Ooops.

#142
post #46

I learned a rather unusual trick to keep myself safe from unintended glob matches. It is not "fool"-proof, but it will probably dilute an unmitigated disaster into an incomplete disaster: Keep a file named -i in the sensitive directories. When glob picks it up, which should be fairly early, it will be treated like a command line argument. Has saved me on occasions. I also had a friend in school who used to, for whate…

I hate that feeling you get in the pit of your stomach after you realize what's happening. Same thing when you forget the WHERE on a DELETE FROM.

SQL is desperately in need of some updates.

For starters, DELETE FROM should never be allowed without a WHERE clause. DBs should simply define that as malformed sql.

Re: Ooops.

#143

Unix could really do with a command that you can wrap around this type of call. Either a sanity check on the path part or a safe rm alternative that contains it. I would gladly give up full rm access to know that I can safely (or safer-ly) delete in scripts. It could be something as simple as a file with paths on each line it - match one path or a path with a glob - and the script fails before destroying anything imp…

Ah. It seems I have just described 'safe-rm'.

Great minds etc :)

Re: Ooops.

#144
post #127

Earlier quoted context omitted.

I hate that feeling you get in the pit of your stomach after you realize what's happening. Same thing when you forget the WHERE on a DELETE FROM.

DELETE FROM? Try TRUNCATE TABLE CUSTOMER ... that one skips the transaction log too, no ROLLBACK possible.

You can't accidentally write a TRUNCATE statement though.

Re: Ooops.

#145
post #127

Earlier quoted context omitted.

I hate that feeling you get in the pit of your stomach after you realize what's happening. Same thing when you forget the WHERE on a DELETE FROM.

DELETE FROM? Try TRUNCATE TABLE CUSTOMER ... that one skips the transaction log too, no ROLLBACK possible.

[deleted]

Re: Ooops.

#146
A decade ago, I worked on a DNA sequencer / aligner product. This produced easily 1GB+ raw data files, and they typically exploded by a factor of ten by the time you performed a bunch of cleaning, smoothing, filtering, etc on them. For several reasons, not least of which was a 4GB file size limit in fat32, this software had to use a directory as a pseudo file.

I was working on some file saving logic. A customer had a problem where they'd overlaid a new logical file on top of an old logical file. Where these actual files, this would just have overwritten the old file, but since these were directories, we got a mishmash of pieces of two different logical files overlaid in the same directory, and of course our software got confused as hell. So, I wrote code that, in case you saved a new file as an extent filename (really directory name), would perform the equivalent of

  rm -rf $dirname; mkdir $dirname;
You can see where this is going... Some grad student didn't understand this, and named a pseudo file as the root directory of a tree of research. Two years of research vanished into the ether, despite a dialog box that had red text in it. That sucked.

Re: Ooops.

#147
post #96

Earlier quoted context omitted.

I do that now, too. I have a trigger-happy semicolon finger.

My method is to write each DELETE as a SELECT first. This has the benefit of actually verifying the DELETE you were about to write.

Doesn't work when you're writing a stored proc.

Re: Ooops.

#148

Perhaps because I'm not a GitHub user, and because I've only ever peeked at HNers' GitHub accounts, but I was always under the impression that given the nature of the service, it would have an early-days-of-HN feel wrt to user behaviour. It was a little disheartening to see the number of Reddit-esque comments that are simply a couple of words along the lines of "omfg" and a constant stream of meme abuse. I expected b…

Actually, your comment sounds more like r/programming than anything I've seen on HN lately. Github comments are usually on-point, because nobody comments on github-hosted projects unless they're actually working on the project. The exception is when somebody does a funny commit, and it gets circulated through...you guess it, HN, reddit, etc.

Exactly. This isn't representative of 'the github community', it's more like 'the subsection of the reddit/hn/etc communities that feel the need to post funny pictures using their github accounts to do it'

Re: Ooops.

#149

Earlier quoted context omitted.

Do you not find that a lack of wide installation limits its usefulness?

I just use it for my boxes. It doesn't stop me putting something silly in a make file (as in the example here), but it does stop me getting burnt by it.

I see; thank you.

Re: Ooops.

#150
Back in the late 90s I worked on a small Windows product... our CEO complained that when the uninstaller ran, it left the empty directory behind along with some small temp files created by the software (that the package hadn't put there during install). So the guy making the package added a command to remove the directory and its contents...

... and the first reporter to try software, for reasons I'll never totally understand, chose to install it in C:\. Worked great until he went to uninstall it.

Post reply on HN