mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
first cut at file to clean up variant trees by removing anything not
under version control
This commit is contained in:
parent
b085aeeb46
commit
c06f0e157d
1 changed files with 75 additions and 0 deletions
75
xwords4/android/scripts/rm-non-git.sh
Executable file
75
xwords4/android/scripts/rm-non-git.sh
Executable file
|
@ -0,0 +1,75 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -u -e
|
||||
|
||||
EXCEPTS=" "
|
||||
|
||||
echo "$0 $*"
|
||||
pwd
|
||||
|
||||
usage() {
|
||||
[ $# -ge 1 ] && echo "ERROR: $1"
|
||||
echo "usage: $0 [--except path/to/file]*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# rm_not_excepted() {
|
||||
# FILE=$1
|
||||
# for EXCEPT in $EXCEPTS; do
|
||||
# if [ $EXCEPT = $FILE ]; then
|
||||
# echo "skipping delete of $FILE"
|
||||
# FILE=""
|
||||
# break
|
||||
# fi
|
||||
# done
|
||||
|
||||
# [ -n "$FILE" ] && rm $FILE
|
||||
# }
|
||||
|
||||
rm_in() {
|
||||
echo "rm_in $1"
|
||||
for FILE in $(ls $1); do
|
||||
FILE=$1/$FILE
|
||||
echo "FILE: $FILE"
|
||||
if [ ! "${EXCEPTS}" = "${EXCEPTS# $FILE }" ]; then
|
||||
echo "$FILE is in $EXCEPTS"
|
||||
continue
|
||||
elif [ -d $FILE ]; then
|
||||
rm_in $FILE
|
||||
elif git ls-files $FILE --error-unmatch 2>/dev/null; then
|
||||
echo "$FILE is a git file"
|
||||
continue
|
||||
else
|
||||
echo "rm $FILE"
|
||||
rm $FILE
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
while [ $# -ge 1 ]; do
|
||||
case $1 in
|
||||
--except)
|
||||
FILE=$2
|
||||
shift
|
||||
if [ $FILE != ${FILE#/} ]; then # starts with / ?
|
||||
: # leave it along
|
||||
elif [ "$FILE" != "${FILE#\./}" ]; then # starts with ./ ?
|
||||
: # leave it alone
|
||||
else
|
||||
FILE="./${FILE}" # prepend ./ to match ls output
|
||||
fi
|
||||
EXCEPTS=" $EXCEPTS $FILE "
|
||||
;;
|
||||
*)
|
||||
usage "unexpected param $1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
echo "EXCEPTS: $EXCEPTS"
|
||||
exit 0
|
||||
|
||||
rm_in "."
|
||||
echo "$0: exiting cleanly"
|
Loading…
Add table
Reference in a new issue