rm-blacklist

Python wrapper for POSIX rm that checks every argument against a blacklist.
git clone git://git.stephanospavlou.info/rm-blacklist.git
Log | Files | Refs | README | LICENSE

README.md (2047B)


      1 # rm-blacklist
      2 Python wrapper for the POSIX ``rm`` command that checks every argument against a
      3 user maintained blacklist.
      4 
      5 ## Installation
      6 Clone this repository with the command:
      7 
      8 ```
      9 git clone https://github.com/stephanospavlou/rm-blacklist
     10 ```
     11 
     12 Add the following aliases to your shell:
     13 
     14 ```
     15 alias rm="PATH/TO/rm-blacklist.py"
     16 alias blacklist="PATH/TO/blacklist.py"
     17 ```
     18 
     19 Then, in the files ``rm-blacklist.py`` and ``blacklist.py``, edit the value of
     20 the constant ``blacklistPath`` so  that it points (absolute path) to the file
     21 ``.blklst``, wherever you may want to place it in your filesystem.
     22 
     23 And finally, ensure that both ``rm-blacklist.py`` and ``blacklist.py`` are
     24 executable.
     25 
     26 ## Blacklisting files
     27 ### Using ``blacklist.py``
     28 The helper script ``blacklist.py`` can be used to add files (or directories) to
     29 the blacklist. Using it looks like this:
     30 
     31 ```
     32 blacklist [-r] <file | directory> <file2 | directory> ...
     33 ```
     34 
     35 The flag ``-r`` is optional: If used, it will blacklist the directory passed
     36 as well as all files (and directories) contained within it recursively. This
     37 flag is only recognized if it is used as the first argument to the script.
     38 
     39 Note that blacklisting a directory without using the ``-r`` flag prevents 
     40 deletion of the directory by ``rm`` **but not its contents**. That is:
     41 
     42 ```
     43 $ blacklist dir
     44 $ rm -rf dir
     45 $ rm-blacklist: either dir or its contents are blacklisted
     46 ```
     47 ``rm-blacklist`` catches blacklisted directory.
     48 
     49 ```
     50 $ blacklist dir
     51 $ rm -rf dir/*
     52 $ 
     53 ```
     54 ``rm-blacklist`` does not prevent the deletion of the contents of
     55 ``blacklisted_dir``.
     56 
     57 ``blacklist.py`` does not check whether or not a file (or directory) has already
     58 been blacklisted before adding it to the blacklist.
     59 
     60 ### Manually
     61 Alternatively, files can be manually blacklisted. This can be done by placing
     62 the absolute path of each file you wish to blacklist on a separate line in
     63 ``.blklst``. Lines starting with ``#`` will be ignored.
     64 
     65 Remember: Blacklisting a directory only prevents the deletion of the *directory*
     66 by ``rm``, **not its contents**.