]> git.wh0rd.org - home.git/commitdiff
cvs-import: modernize a bit
authorMike Frysinger <vapier@gentoo.org>
Wed, 5 Aug 2015 13:39:20 +0000 (09:39 -0400)
committerMike Frysinger <vapier@gentoo.org>
Wed, 5 Aug 2015 13:39:20 +0000 (09:39 -0400)
.bin/cvs-import

index f30b22578eafebda40971fa1f7a7d962a063adcf..d11ad9fc6404c8f0b8e49bf4bf0e3f62d193b975 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+set -e
+
 if [[ $# -eq 0 ]] || [[ $1 == "-h" ]] ; then
        echo "Usage: ${0##*/} <dir to import> [more dirs]"
        exit 1
@@ -13,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"