.tui
This commit is contained in:
@@ -38,3 +38,9 @@
|
|||||||
## v2 update
|
## v2 update
|
||||||
- The bottom empty row now visibly shows the cursor.
|
- The bottom empty row now visibly shows the cursor.
|
||||||
- When TUI exits normally, the shell integration changes the parent Bash shell to the directory where TUI was closed.
|
- When TUI exits normally, the shell integration changes the parent Bash shell to the directory where TUI was closed.
|
||||||
|
|
||||||
|
## v2 fix – interactive shell commands and exit directory
|
||||||
|
|
||||||
|
- Fixed interactive action commands: the command loop no longer redirects stdin from the command file.
|
||||||
|
- Commands such as `unzip -l <path> && read -rp "Enter..." || read -rp "FAILED..."` now receive input from the real terminal.
|
||||||
|
- The final TUI directory is always applied to the parent Bash shell when TUI exits, including Ctrl+C/SIGINT.
|
||||||
|
|||||||
@@ -70,11 +70,16 @@ tui() {
|
|||||||
# change the parent Bash shell to the directory where TUI was
|
# change the parent Bash shell to the directory where TUI was
|
||||||
# actually closed. This includes Ctrl+C (status 130).
|
# actually closed. This includes Ctrl+C (status 130).
|
||||||
if (( rc != 42 )); then
|
if (( rc != 42 )); then
|
||||||
cd "$tui_cwd" || {
|
# The TUI writes its actual final directory in cwd_file in its
|
||||||
|
# finally block. Always apply it to the parent Bash shell before
|
||||||
|
# handling the exit status, including SIGINT/Ctrl+C.
|
||||||
|
if cd "$tui_cwd"; then
|
||||||
|
rm -f "$command_file" "$cwd_file"
|
||||||
|
else
|
||||||
|
printf 'tui: cannot cd to final directory: %s\n' "$tui_cwd" >&2
|
||||||
rm -f "$command_file" "$cwd_file"
|
rm -f "$command_file" "$cwd_file"
|
||||||
return 1
|
return 1
|
||||||
}
|
fi
|
||||||
rm -f "$command_file" "$cwd_file"
|
|
||||||
if (( rc == 130 )); then
|
if (( rc == 130 )); then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -90,7 +95,12 @@ tui() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
while IFS= read -r cmd; do
|
# Do not redirect stdin while executing commands: commands may need
|
||||||
|
# interactive input (for example `read`, `joe`, or `less`). Read the
|
||||||
|
# command list into an array first, then let each command inherit the
|
||||||
|
# real terminal stdin.
|
||||||
|
mapfile -t tui_commands < "$command_file"
|
||||||
|
for cmd in "${tui_commands[@]}"; do
|
||||||
[[ -z "$cmd" ]] && continue
|
[[ -z "$cmd" ]] && continue
|
||||||
|
|
||||||
history -s -- "$cmd"
|
history -s -- "$cmd"
|
||||||
@@ -102,7 +112,7 @@ tui() {
|
|||||||
read -rp 'Tryck Enter för att fortsätta...' _
|
read -rp 'Tryck Enter för att fortsätta...' _
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done < "$command_file"
|
done
|
||||||
|
|
||||||
popd >/dev/null || true
|
popd >/dev/null || true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user