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

I didn't see this mentioned in the article, but you can protect against this in your own scripts by including a -- before user-supplied parameters, which prevents them from being treated as flags.

    $ rm -- -rf
    rm: cannot remove '-rf': No such file or directory
(see Guideline 10, http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_...)



It should be noted that you will run plenty of programs in the wild that don't respect this convention.


Alternatively:

  $ rm ./-rf


That if you know such file exist in said folder.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: