Hacker News new | comments | show | ask | jobs | submit login

svckr 2 hours ago | link [dead]

Reminds me of the "most stupid thing" I ever typed into Terminal.app. I somehow managed to create a subdirectory named "~", and decided it was a good idea to do this:

    rm -rf ~
It took me about 5 seconds to realize the command should have returned immediately, and frantically press Ctrl-c. But that was all that was needed to ruin two week worth of code.

If you want to try a fun little experiment, type this command into your colleague's shell and see what happens (and how long it takes):

    mkdir ./~



Yep, did that in 2007. Let it run for minutes because I wasn't at my Mac. By the time I got back, I had a lot of free disk space and the stubborn '~' folder was still there since it was outside my home directory. Since then I used Time Machine or now CrashPlan to ensure I don't ever lose local files, accidentally deleted, again.


> If you want to try a fun little experiment, type this command into your colleague's shell and see what happens (and how long it takes):

> mkdir ./~

  $ time mkdir ./~

  real	0m0.007s
  user	0m0.000s
  sys	0m0.004s
I don't get it. What's fun about this experiment?


The user will ls their home directory, see this file, and attempt to rm it. The shell will instruct rm to remove their home directory instead.


Ah. I feel a bit stupid for taking that so literally.

So, when i delete a directory, whenever possible, i use the rmdir command. rmdir refuses to delete a directory which isn't empty. It's a really handy safety check. If a colleague dropped a tilde directory on me, the process would go:

Well, i'll just delete that.

  $ rmdir ~
  rmdir: /home/twic: Directory not empty
Oh bugger, of course. Better quote it.'

  $ rmdir '~'
Right, now i will proceed to give my colleague a Chinese burn.


Y u no source version control?


Local git repos, mostly. But I learned my lesson. Ever since that incident every LOC is pushed to GitHub, no matter how silly/hacky/not-yet-ready it is.




Applications are open for YC Winter 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: