"Fossies" - the Fresh Open Source Software Archive

Member "bup-0.30/t/force-delete" (28 Sep 2019, 629 Bytes) of package /linux/privat/bup-0.30.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env bash
    2 
    3 set -o pipefail
    4 
    5 # Try *hard* to delete $@.  Among other things, some systems have
    6 # r-xr-xr-x for root and other system dirs.
    7 
    8 rc=0
    9 rm -rf "$@" # Maybe we'll get lucky.
   10 for f in "$@"; do
   11     test -e "$f" || continue
   12     if test "$(type -p setfacl)"; then
   13         setfacl -Rb "$f"
   14     fi
   15     if test "$(type -p chattr)"; then
   16         chattr -R -aisu "$f"
   17     fi
   18     chmod -R u+rwX "$f"
   19     rm -r "$f"
   20     if test -e "$f"; then
   21         rc=1
   22         find "$f" -ls
   23         lsattr -aR "$f"
   24         getfacl -R "$f"
   25     fi
   26 done
   27 
   28 if test "$rc" -ne 0; then
   29     echo "Failed to delete everything" 1>&2
   30 fi
   31 
   32 exit "$rc"