@@ -109,25 +109,25 @@ chmod +x test_graceful_stop.sh
109109output=$( ./test_graceful_stop.sh " $TEST_BASE " " $PROJECT_ROOT " 2>&1 )
110110
111111# Verify the output contains expected messages
112- if echo " $output " | grep -q " RESTORE_TERMINAL_CALLED" ; then
112+ if grep -q " RESTORE_TERMINAL_CALLED" <<< " $output " ; then
113113 pass " _restore_terminal was called"
114114else
115115 fail " _restore_terminal call" " Function not called"
116116fi
117117
118- if echo " $output " | grep -q " CLEANUP_CALLED" ; then
118+ if grep -q " CLEANUP_CALLED" <<< " $output " ; then
119119 pass " _cleanup was called"
120120else
121121 fail " _cleanup call" " Function not called"
122122fi
123123
124- if echo " $output " | grep -q " Monitoring stopped:" ; then
124+ if grep -q " Monitoring stopped:" <<< " $output " ; then
125125 pass " Graceful stop message displayed"
126126else
127127 fail " Graceful stop message" " Message not found"
128128fi
129129
130- if echo " $output " | grep -q " directory no longer exists" ; then
130+ if grep -q " directory no longer exists" <<< " $output " ; then
131131 pass " User-friendly reason in message"
132132else
133133 fail " User-friendly reason" " Reason not in message"
@@ -170,7 +170,7 @@ TESTSCRIPT
170170chmod +x test_double_cleanup.sh
171171output=$( ./test_double_cleanup.sh 2>&1 )
172172
173- if echo " $output " | grep -q " FINAL_COUNT: 1" ; then
173+ if grep -q " FINAL_COUNT: 1" <<< " $output " ; then
174174 pass " Cleanup only executed once (idempotent)"
175175else
176176 fail " Idempotent cleanup" " Cleanup executed multiple times"
@@ -232,19 +232,19 @@ TESTSCRIPT
232232chmod +x test_loop_detection.sh
233233output=$( ./test_loop_detection.sh " $TEST_BASE " 2>&1 )
234234
235- if echo " $output " | grep -q " CONTINUING" ; then
235+ if grep -q " CONTINUING" <<< " $output " ; then
236236 pass " Monitor continues while directory exists"
237237else
238238 fail " Directory existence check" " Stopped while directory exists"
239239fi
240240
241- if echo " $output " | grep -q " STOPPED_AFTER_DELETE" ; then
241+ if grep -q " STOPPED_AFTER_DELETE" <<< " $output " ; then
242242 pass " Monitor detects deletion and stops gracefully"
243243else
244244 fail " Deletion detection" " Did not stop after deletion"
245245fi
246246
247- if echo " $output " | grep -q " GRACEFUL_STOP" ; then
247+ if grep -q " GRACEFUL_STOP" <<< " $output " ; then
248248 pass " Graceful stop triggered on deletion"
249249else
250250 fail " Graceful stop trigger" " Not triggered"
@@ -290,13 +290,13 @@ TESTSCRIPT
290290chmod +x test_terminal_restore.sh
291291output=$( ./test_terminal_restore.sh " $TEST_BASE " " $PROJECT_ROOT " 2>&1 )
292292
293- if echo " $output " | grep -q " FUNCTION_DEFINED" ; then
293+ if grep -q " FUNCTION_DEFINED" <<< " $output " ; then
294294 pass " _restore_terminal function is defined"
295295else
296296 fail " _restore_terminal definition" " Function not found"
297297fi
298298
299- if echo " $output " | grep -q " SCROLL_REGION_RESET" ; then
299+ if grep -q " SCROLL_REGION_RESET" <<< " $output " ; then
300300 pass " _restore_terminal resets scroll region"
301301else
302302 fail " Scroll region reset" " Reset command not found"
@@ -393,7 +393,7 @@ TESTSCRIPT
393393chmod +x test_sigint_bash.sh
394394output=$( ./test_sigint_bash.sh 2>&1 )
395395
396- if echo " $output " | grep -q " CLEANUP_BY_SIGINT" ; then
396+ if grep -q " CLEANUP_BY_SIGINT" <<< " $output " ; then
397397 pass " SIGINT triggers _cleanup in bash"
398398else
399399 fail " SIGINT in bash" " Cleanup not triggered"
@@ -494,11 +494,11 @@ TESTSCRIPT
494494 # Run in subshell to prevent SIGINT propagation to parent
495495 output=$( bash -c ' trap "" INT; zsh test_sigint_zsh.zsh 2>&1' || true)
496496
497- if echo " $output " | grep -q " CLEANUP_BY_SIGINT_ZSH" ; then
497+ if grep -q " CLEANUP_BY_SIGINT_ZSH" <<< " $output " ; then
498498 pass " SIGINT triggers TRAPINT cleanup in zsh"
499499 else
500500 # zsh might handle signals differently, check if it at least ran
501- if echo " $output " | grep -q " ZSH_SIGINT_HANDLED" ; then
501+ if grep -q " ZSH_SIGINT_HANDLED" <<< " $output " ; then
502502 pass " SIGINT triggers TRAPINT cleanup in zsh"
503503 else
504504 fail " SIGINT in zsh" " TRAPINT cleanup not triggered: $output "
0 commit comments