Refactor the repo sync script to work in strict mode
This commit is contained in:
parent
e0c33b01b7
commit
72e018514e
1 changed files with 24 additions and 12 deletions
|
|
@ -1,4 +1,7 @@
|
||||||
#! /usr/bin/sh
|
#! /usr/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
|
||||||
REPO_ROOT_FILE="$(systemd-path user-state-private)"/repo-roots/repo-roots
|
REPO_ROOT_FILE="$(systemd-path user-state-private)"/repo-roots/repo-roots
|
||||||
|
|
||||||
|
|
@ -12,18 +15,27 @@ sync_repo () {
|
||||||
repo=$1
|
repo=$1
|
||||||
|
|
||||||
echo git-sync "${repo}"
|
echo git-sync "${repo}"
|
||||||
|
set +e
|
||||||
( cd "${repo}" && "$(systemd-path user-state-private)"/git-sync/git-sync sync )
|
( cd "${repo}" && "$(systemd-path user-state-private)"/git-sync/git-sync sync )
|
||||||
|
set -e
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "list" = "$1" ]; then
|
case "${1:-sync}" in
|
||||||
|
"list")
|
||||||
while read -r repo_root; do
|
while read -r repo_root; do
|
||||||
list_repos "${repo_root}"
|
list_repos "${repo_root}"
|
||||||
done < "${REPO_ROOT_FILE}"
|
done < "${REPO_ROOT_FILE}"
|
||||||
else
|
;;
|
||||||
|
"sync")
|
||||||
while read -r repo_root; do
|
while read -r repo_root; do
|
||||||
for repo in $(list_repos "${repo_root}"); do
|
for repo in $(list_repos "${repo_root}"); do
|
||||||
sync_repo "${repo}"
|
sync_repo "${repo}"
|
||||||
done
|
done
|
||||||
done < "${REPO_ROOT_FILE}"
|
done < "${REPO_ROOT_FILE}"
|
||||||
fi
|
;;
|
||||||
|
*)
|
||||||
|
echo Unknown option \""$1"\"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue