Last active
January 8, 2019 14:05
-
-
Save larshb/a72327eb36128e9c7b42fdd9494c92cd to your computer and use it in GitHub Desktop.
SVN clean and delete all unversioned/ignored files/folders in my working directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# make sure this script exits with a non-zero return value if the | |
# current directory is not in a svn working directory | |
svn info >/dev/null || exit 1 | |
svn status --no-ignore | grep '^[I?]' | cut -c 9- | | |
# setting IFS to the empty string ensures that any leading or | |
# trailing whitespace is not trimmed from the filename | |
while IFS= read -r f; do | |
# tell the user which file is being deleted. use printf | |
# instead of echo because different implementations of echo do | |
# different things if the arguments begin with hyphens or | |
# contain backslashes; the behavior of printf is consistent | |
printf '%s\n' "Deleting ${f}..." | |
# if rm -rf can't delete the file, something is wrong so bail | |
rm -rf "${f}" || exit 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment