]> git.wh0rd.org - home.git/blobdiff - .bin/cvs-import
crostini-vapier-setup: install edge
[home.git] / .bin / cvs-import
index 754dbe7d98a4a83a766657de6a2d37fc98017c61..d11ad9fc6404c8f0b8e49bf4bf0e3f62d193b975 100755 (executable)
@@ -1,5 +1,12 @@
 #!/bin/bash
 
+set -e
+
+if [[ $# -eq 0 ]] || [[ $1 == "-h" ]] ; then
+       echo "Usage: ${0##*/} <dir to import> [more dirs]"
+       exit 1
+fi
+
 dir=$1
 if [[ ! -e ${dir} ]] ; then
        echo "cvs-import: $1: directory does not exist" 1>&2
@@ -8,19 +15,22 @@ fi
 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"