@@ -95,12 +95,12 @@ cd "${ddpath}" | ${bin} install -f -c "${cfg}" --verbose -p p1
9595# Remove a file from blockme1, reinstall, and check it is restored (block behavior)
9696rm -f " ${instroot} /blockme1/file1.txt"
9797cd " ${ddpath} " | ${bin} install -f -c " ${cfg} " --verbose -p p1
98- [ -f " ${instroot} /blockme1/file1.txt" ] || (echo " blockme1 not restored as block " && exit 1)
98+ [ -f " ${instroot} /blockme1/file1.txt" ] || (echo " blockme1 not restored" && exit 1)
9999
100- # Remove a file from noblock, reinstall, and check it is NOT restored (not a block)
100+ # Remove a file from noblock, reinstall, and check it is restored
101101rm -f " ${instroot} /noblock/file4.txt"
102102cd " ${ddpath} " | ${bin} install -f -c " ${cfg} " --verbose -p p1
103- [ ! -f " ${instroot} /noblock/file4.txt" ] || (echo " noblock should not be restored as block " && exit 1)
103+ [ -f " ${instroot} /noblock/file4.txt" ] || (echo " noblock not restored" && exit 1)
104104
105105# Check that blockme2 was installed as a block
106106rm -f " ${instroot} /blockme2/file3.txt"
@@ -124,5 +124,79 @@ rm -f "${instroot}/blockme1/nomatchsub/subfile2.txt"
124124cd " ${ddpath} " | ${bin} install -f -c " ${cfg} " --verbose -p p1
125125[ ! -f " ${instroot} /blockme1/nomatchsub/subfile2.txt" ] || (echo " blockme1/nomatchsub should not be restored as block" && exit 1)
126126
127+ # Check confirmation prompts for block and non-block directories
128+ # Remove -f to enable confirmation prompts
129+
130+ # Function to count confirmation prompts in output
131+ count_prompts () {
132+ grep -c " Do you want to continue" " $1 "
133+ }
134+
135+ # Test: blockme1 (should prompt ONCE for the whole dir)
136+ rm -rf " ${instroot} /blockme1"
137+ # Use script to simulate 'y' input and capture output
138+ script -q -c " cd \" ${ddpath} \" && ${bin} install -c \" ${cfg} \" --verbose -p p1" blockme1.out <<< ' y'
139+ blockme1_prompts=$( count_prompts blockme1.out)
140+ if [ " $blockme1_prompts " -ne 1 ]; then
141+ echo " blockme1: expected 1 prompt, got $blockme1_prompts " && exit 1
142+ fi
143+
144+ # Test: noblock (should prompt for each file)
145+ rm -rf " ${instroot} /noblock"
146+ script -q -c " cd \" ${ddpath} \" && ${bin} install -c \" ${cfg} \" --verbose -p p1" noblock.out <<< ' y
147+ y'
148+ noblock_prompts=$( count_prompts noblock.out)
149+ # There is only one file, so expect 1 prompt
150+ if [ " $noblock_prompts " -ne 1 ]; then
151+ echo " noblock: expected 1 prompt, got $noblock_prompts " && exit 1
152+ fi
153+
154+ # Test: blockme1 with multiple files (should still prompt ONCE)
155+ rm -rf " ${instroot} /blockme1"
156+ # Add another file to blockme1
157+ echo " fileX" > " ${dotpath} /blockme1/fileX.txt"
158+ script -q -c " cd \" ${ddpath} \" && ${bin} install -c \" ${cfg} \" --verbose -p p1" blockme1_multi.out <<< ' y'
159+ blockme1_multi_prompts=$( count_prompts blockme1_multi.out)
160+ if [ " $blockme1_multi_prompts " -ne 1 ]; then
161+ echo " blockme1 (multi): expected 1 prompt, got $blockme1_multi_prompts " && exit 1
162+ fi
163+
164+ # Test: blockme1/nomatchsub (should prompt for each file in non-block subdir)
165+ rm -rf " ${instroot} /blockme1/nomatchsub"
166+ script -q -c " cd \" ${ddpath} \" && ${bin} install -c \" ${cfg} \" --verbose -p p1" nomatchsub.out <<< ' y'
167+ nomatchsub_prompts=$( count_prompts nomatchsub.out)
168+ # Only one file, so expect 1 prompt
169+ if [ " $nomatchsub_prompts " -ne 1 ]; then
170+ echo " nomatchsub: expected 1 prompt, got $nomatchsub_prompts " && exit 1
171+ fi
172+
173+ # Test: blockme1/matchsub (should prompt ONCE for the whole subdir)
174+ rm -rf " ${instroot} /blockme1/matchsub"
175+ script -q -c " cd \" ${ddpath} \" && ${bin} install -c \" ${cfg} \" --verbose -p p1" matchsub.out <<< ' y'
176+ matchsub_prompts=$( count_prompts matchsub.out)
177+ if [ " $matchsub_prompts " -ne 1 ]; then
178+ echo " matchsub: expected 1 prompt, got $matchsub_prompts " && exit 1
179+ fi
180+
181+ # Check confirmation prompt count for block directory
182+ rm -f " ${instroot} /blockme1/file1.txt"
183+ # Run install interactively and capture output
184+ prompt_output_block=$( cd " ${ddpath} " && echo y | ${bin} install -c " ${cfg} " --verbose -p p1 2>&1 )
185+ # Count confirmation prompts (look for 'Overwrite' or 'replace' or similar)
186+ prompt_count_block=$( echo " $prompt_output_block " | grep -E -i ' overwrite|replace|confirm' | wc -l)
187+ if [ " $prompt_count_block " -ne 1 ]; then
188+ echo " Expected 1 confirmation prompt for block directory, got $prompt_count_block " && exit 1
189+ fi
190+
191+ # Check confirmation prompt count for non-block directory
192+ rm -f " ${instroot} /noblock/file4.txt"
193+ # Run install interactively and capture output
194+ prompt_output_noblock=$( cd " ${ddpath} " && echo y | ${bin} install -c " ${cfg} " --verbose -p p1 2>&1 )
195+ # Count confirmation prompts (should be at least 1 for the file, could be more if more files)
196+ prompt_count_noblock=$( echo " $prompt_output_noblock " | grep -E -i ' overwrite|replace|confirm' | wc -l)
197+ if [ " $prompt_count_noblock " -lt 1 ]; then
198+ echo " Expected at least 1 confirmation prompt for non-block directory, got $prompt_count_noblock " && exit 1
199+ fi
200+
127201echo " OK"
128202exit 0
0 commit comments