fortrangoingonforty/fortress / 3051327

Browse files

fix runtime errors on switching terminal modes

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
305132726d2d60bf5ff493dd9904f20226346476
Parents
729fe22
Tree
d790b36

2 changed files

StatusFile+-
M build-rpm.sh 7 7
M src/git/git_ops.f90 11 8
build-rpm.shmodified
@@ -21,13 +21,13 @@ mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
2121
 echo "▶ Creating source tarball..."
2222
 # Create source tarball (excluding build artifacts and git)
2323
 tar --exclude='.git' \
24
-    --exclude='build' \
25
-    --exclude='*.rpm' \
26
-    --exclude='*.tar.gz' \
27
-    --exclude='rpmbuild' \
28
-    --transform "s,^.,$NAME-$VERSION," \
29
-    -czf ~/rpmbuild/SOURCES/$NAME-$VERSION.tar.gz \
30
-    .
24
+  --exclude='build' \
25
+  --exclude='*.rpm' \
26
+  --exclude='*.tar.gz' \
27
+  --exclude='rpmbuild' \
28
+  --transform "s,^.,$NAME-$VERSION," \
29
+  -czf ~/rpmbuild/SOURCES/$NAME-$VERSION.tar.gz \
30
+  .
3131
 
3232
 echo "✓ Tarball created: ~/rpmbuild/SOURCES/$NAME-$VERSION.tar.gz"
3333
 
src/git/git_ops.f90modified
@@ -317,7 +317,7 @@ contains
317317
         read(*, '(a)', iostat=ios) commit_msg
318318
 
319319
         ! Restore raw mode
320
-        call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null")
320
+        call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null", wait=.true.)
321321
 
322322
         if (ios == 0 .and. len_trim(commit_msg) > 0) then
323323
             ! Execute git commit (use single quotes for message to avoid escaping issues)
@@ -367,7 +367,7 @@ contains
367367
             write(output_unit, '(a)') RED // "No upstream selected." // RESET
368368
             call execute_command_line("sleep 1")
369369
             ! Re-enable raw mode
370
-            call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null")
370
+            call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null", wait=.true.)
371371
             call execute_command_line("rm -f " // trim(temp_file) // " 2>/dev/null")
372372
             return
373373
         end if
@@ -395,7 +395,7 @@ contains
395395
 
396396
         call execute_command_line("rm -f " // trim(temp_file) // " 2>/dev/null")
397397
         ! Re-enable raw mode
398
-        call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null")
398
+        call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null", wait=.true.)
399399
     end subroutine prompt_upstream_selection
400400
 
401401
     subroutine git_push_prompt(dir, repo_name)
@@ -472,7 +472,7 @@ contains
472472
             read(*, '(a)', iostat=ios) tag_message
473473
 
474474
             ! Restore raw mode
475
-            call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null")
475
+            call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null", wait=.true.)
476476
 
477477
             if (ios == 0) then
478478
                 ! Execute git tag
@@ -501,7 +501,7 @@ contains
501501
             end if
502502
         else
503503
             ! Restore raw mode if tag name was empty
504
-            call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null")
504
+            call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null", wait=.true.)
505505
         end if
506506
     end subroutine git_tag_prompt
507507
 
@@ -510,6 +510,7 @@ contains
510510
         logical, intent(in) :: is_staged, is_unstaged
511511
         character(len=MAX_PATH*2) :: git_cmd
512512
         character(len=1) :: key
513
+        integer :: ios
513514
 
514515
         ! Clear screen
515516
         write(output_unit, '(a)', advance='no') CLEAR
@@ -538,9 +539,11 @@ contains
538539
         write(output_unit, *)
539540
         write(output_unit, '(a)') GREY // "Press any key to return..." // RESET
540541
 
541
-        ! Restore raw mode before reading
542
-        call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null")
543
-        read(*, '(a1)', advance='no') key
542
+        ! Restore raw mode and give terminal time to settle
543
+        call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null && sleep 0.05", wait=.true.)
544
+
545
+        ! Read keypress with error handling for any buffering issues
546
+        read(*, '(a1)', advance='no', iostat=ios) key
544547
     end subroutine show_git_diff_fullscreen
545548
 
546549
     subroutine git_fetch_prompt(dir, repo_name)