#!/bin/bash
+set -e
+
if [[ $# -eq 0 ]] || [[ $1 == "-h" ]] ; then
echo "Usage: ${0##*/} <dir to import> [more dirs]"
exit 1
dir=$(realpath "${dir}")
echo "Importing ${dir} and kids"
-cd ${dir}/..
-cvs -Q add ${dir##*/}
+cd "${dir}/.."
+cvs -Q add "${dir##*/}"
find_files() {
- find . -mindepth $1 -maxdepth $1 '!' '(' -name 'CVS' -o -wholename '*/CVS/*' ')' -print0
+ local depth=$1
+ shift
+ find . -mindepth ${depth} -maxdepth ${depth} \
+ '!' '(' -name 'CVS' -o -wholename '*/CVS/*' ')' "$@"
}
-cd ${dir}
+cd "${dir}"
i=1
while [[ -n $(find_files ${i}) ]] ; do
echo "Importing at depth ${i}"
- find_files ${i} | xargs -0 cvs -Q add
- ((++i))
+ find_files ${i} -exec cvs -Q add {} +
+ : $(( i += 1 ))
done
echo "Done"