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

"Not to mention how dangerous it is to use. Accidentally type the > symbol? Enjoy overwriting whichever file came after in the command."

At least in zsh, you can prevent such mistakes by

  setopt NO_CLOBBER
It's saved my bacon many times.

Also, from bitter experience I've forced myself to get in to the habit of never typing:

  rm *
but instead always doing:

  cd ..
  rm foo/*
It forces me to be more conscious of what I'm deleting.



I have `alias rm="echo DISABLED"` in my shell rc, and I have `trash` defined as a big shell function that safely moves stuff to the x desktop trash bin without clobbering anything. It's mildly irritating, but it gives me incredible peace of mind.


> in zsh […] setopt NO_CLOBBER

In Bash it’s

  set -o noclobber
or

  set -C


Those work in any POSIX shell, and also zsh.





Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: