diff --git a/bin/_common.sh b/bin/_common.sh index ae7c4b2..e23084e 100644 --- a/bin/_common.sh +++ b/bin/_common.sh @@ -1,7 +1,9 @@ # Shared by the bin/ helpers. The main checkout holds the venv and the # (gitignored) vault files that every worktree uses. repo=$(git rev-parse --show-toplevel) -main_checkout=$(git -C "$repo" worktree list --porcelain | awk '/^worktree /{print $2; exit}') +# awk reads to the end: exiting early kills git with SIGPIPE, which pipefail +# turns into a failed script once there are enough worktrees. +main_checkout=$(git -C "$repo" worktree list --porcelain | awk '/^worktree /&&!found{print $2; found=1}') lock_dir=${XDG_RUNTIME_DIR:-/tmp}/ansible-selfhosting mkdir -p "$lock_dir" && chmod 700 "$lock_dir"