mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
c06f0e157d
under version control
75 lines
1.6 KiB
Bash
Executable file
75 lines
1.6 KiB
Bash
Executable file
#!/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"
|