diff options
author | Erich Eckner <git@eckner.net> | 2021-11-13 11:12:11 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2021-11-13 11:15:37 +0100 |
commit | d1a4727ba0dedcd32543f266edd826815e073f91 (patch) | |
tree | 1678426ced67b86060155d802cea5495ebaf6d70 | |
parent | 1f629475ec584371d573c7f13b5533de17da23bf (diff) | |
download | carddav-alpine-converter-d1a4727ba0dedcd32543f266edd826815e073f91.tar.xz |
carddav-to-alpine: sanity check + write addressbook from scratch
-rwxr-xr-x | carddav-to-alpine | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/carddav-to-alpine b/carddav-to-alpine index db8db31..d6310b2 100755 --- a/carddav-to-alpine +++ b/carddav-to-alpine @@ -4,7 +4,14 @@ error=0 -touch "${git_dir}"'/uids' +for file in 'addressbook' 'uids'; do + if [ -n $(git -C "${git_dir}" diff -- "${file}") ]; then + >&2 printf 'File "%s" was changed relative to git.\n' "${file##*/}" + exit 1 + fi + rm -f "${git_dir}"'/'"${file}" + touch "${git_dir}"'/'"${file}" +done find "${git_dir}" \ -name '.git' \ @@ -42,10 +49,6 @@ find "${git_dir}" \ continue fi - sed -i ' - /^'"${uid}"' /d - ' "${git_dir}"'/uids' - printf '%s\t' \ "${_UID}" \ "${_NICKNAME}" \ |