From ed4a4a5fbdaaa022ed8606f650bd01038d0aa6fe Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Wed, 8 Jul 2020 02:41:49 -0500 Subject: [PATCH] Fix bug with out-of-sync sources The indexes of targets, scores, sources, etc. must be kept in sync. --- yadm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/yadm b/yadm index 57219c8..af5a3bd 100755 --- a/yadm +++ b/yadm @@ -254,8 +254,18 @@ function record_score() { # $YADM_CONFIG must be processed first, in case other templates lookup yadm configurations if [ "$tgt" = "$YADM_CONFIG" ]; then alt_targets=("$tgt" "${alt_targets[@]}") + alt_sources=("$src" "${alt_sources[@]}") alt_scores=(0 "${alt_scores[@]}") index=0 + # increase the index of any existing alt_template_cmds + new_cmds=() + for cmd_index in "${!alt_template_cmds[@]}"; do + new_cmds[$((cmd_index+1))]="${alt_template_cmds[$cmd_index]}" + done + alt_template_cmds=() + for cmd_index in "${!new_cmds[@]}"; do + alt_template_cmds[$cmd_index]="${new_cmds[$cmd_index]}" + done else alt_targets+=("$tgt") # set index to the last index (newly created one)