Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.93 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. directory="${1-$(pwd)}"
  4.  
  5. if [ ! -d "$directory" ]
  6. then
  7.     echo "No such directory: $directory" >&2
  8.     exit 1
  9. fi
  10.  
  11. declare -a fileset
  12.  
  13. while IFS='' read -r f; do
  14.  
  15.     fileset+=("$f")
  16.  
  17. done < <(svn status "$directory" | sed '/^?/!d;s/^?       //')
  18.  
  19. if [[ ! $fileset ]]
  20. then
  21.     echo "There are no unversioned files to remove."
  22.     exit 0
  23. fi
  24.  
  25. echo
  26. echo "WARNING: You are about to remove the following files which have not been versioned in svn:"
  27. echo "--------"
  28. echo
  29. for f in "${fileset[@]}"
  30. do
  31. #   echo "$f"
  32.     echo "${f/#$(pwd)/.}"
  33. done
  34.  
  35. echo
  36. read -p "Confirm? [Y/n]: " response
  37. echo        
  38.  
  39. case "$response" in
  40.  
  41.     y|Y|'')
  42.  
  43.         echo "Removing non-versioned files:"
  44.         echo        
  45.  
  46.         for f in "${fileset[@]}"
  47.         do
  48. #           rm -rfv "$f"
  49.             rm -rfv "${f/#$(pwd)/.}"
  50.         done
  51.        
  52.         ;;
  53.  
  54.     *)
  55.  
  56.         echo "Aborted."
  57.  
  58.         ;;
  59. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement