Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
52
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
  14. do
  15.  
  16.     fileset+=("$f")
  17.  
  18. done < <(svn status "$directory" | sed '/^?/!d;s/^?       //')
  19.  
  20. if [[ ! $fileset ]]
  21. then
  22.     echo "There are no unversioned files to remove."
  23.     exit 0
  24. fi
  25.  
  26. echo
  27. echo "WARNING: You are about to remove the following files which have not been versioned in svn:"
  28. echo "--------"
  29. echo
  30. for f in "${fileset[@]}"
  31. do
  32. #   echo "$f"
  33.     echo "${f/#$(pwd)/.}"
  34. done
  35.  
  36. echo
  37. read -p "Confirm? [Y/n]: " response
  38. echo        
  39.  
  40. case "$response" in
  41.  
  42.     y|Y|'')
  43.  
  44.         echo "Removing non-versioned files:"
  45.         echo        
  46.  
  47.         for f in "${fileset[@]}"
  48.         do
  49. #           rm -rfv "$f"
  50.             rm -rfv "${f/#$(pwd)/.}"
  51.         done
  52.        
  53.         ;;
  54.  
  55.     *)
  56.  
  57.         echo "Aborted."
  58.  
  59.         ;;
  60. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement