From 4e1cd0590bfaeb5c237d3b51f98269ab9ab8a761 Mon Sep 17 00:00:00 2001 From: pagedown Date: Tue, 26 Jul 2022 13:20:50 +0800 Subject: [PATCH] Use builtin to call read in zsh integration and bash integration --- shell-integration/bash/kitty.bash | 18 +++++++++--------- shell-integration/zsh/kitty-integration | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/shell-integration/bash/kitty.bash b/shell-integration/bash/kitty.bash index 5360518cb..cd600ad55 100644 --- a/shell-integration/bash/kitty.bash +++ b/shell-integration/bash/kitty.bash @@ -162,7 +162,7 @@ _ksi_main() { # in particular this means cwd reporting will not happen for a # command like cd /test && cat. PS0 is evaluated before cd is run. if [[ "${_ksi_prompt[last_reported_cwd]}" != "$PWD" ]]; then - _ksi_prompt[last_reported_cwd]="$PWD"; + _ksi_prompt[last_reported_cwd]="$PWD" builtin printf "\e]7;kitty-shell-cwd://%s%s\a" "$HOSTNAME" "$PWD" fi fi @@ -392,27 +392,27 @@ edit-in-kitty() { builtin trap -- "builtin command stty '$old_tty_settings'; _ksi_transmit_data 'abort_signaled=interrupt' 'edit'; builtin exit 1;" SIGINT SIGTERM while :; do started="n" - while IFS= read -r line; do + while IFS= builtin read -r line; do if [ "$started" = "y" ]; then - [ "$line" = "UPDATE" ] && break; + [ "$line" = "UPDATE" ] && break [ "$line" = "DONE" ] && { started="done"; break; } - builtin printf "%s\n" "$line" > /dev/stderr; - return 1; + builtin printf "%s\n" "$line" > /dev/stderr + return 1 else [ "$line" = "KITTY_DATA_START" ] && started="y" fi done - [ "$started" = "n" ] && continue; + [ "$started" = "n" ] && continue data="" - while IFS= read -r line; do - [ "$line" = "KITTY_DATA_END" ] && break; + while IFS= builtin read -r line; do + [ "$line" = "KITTY_DATA_END" ] && break data="$data$line" done [ -n "$data" -a "$started" != "done" ] && { builtin echo "Updating $ed_filename..." builtin printf "%s" "$data" | builtin command base64 -d > "$ed_filename" } - [ "$started" = "done" ] && break; + [ "$started" = "done" ] && break done } $(_ksi_wait_for_complete > /dev/tty) diff --git a/shell-integration/zsh/kitty-integration b/shell-integration/zsh/kitty-integration index ef17b4545..23430260d 100644 --- a/shell-integration/zsh/kitty-integration +++ b/shell-integration/zsh/kitty-integration @@ -474,26 +474,26 @@ edit-in-kitty() { builtin trap "builtin command stty '$old_tty_settings'; _ksi_transmit_data 'abort_signaled=interrupt' 'edit'; return 1;" INT TERM while :; do started="n" - while IFS= read -r line; do + while IFS= builtin read -r line; do if [ "$started" = "y" ]; then [ "$line" = "UPDATE" ] && break; [ "$line" = "DONE" ] && { started="done"; break; } - builtin printf "%s\n" "$line" > /dev/stderr; - return 1; + builtin printf "%s\n" "$line" > /dev/stderr + return 1 else [ "$line" = "KITTY_DATA_START" ] && started="y" fi done - [ "$started" = "n" ] && continue; + [ "$started" = "n" ] && continue data="" - while IFS= read -r line; do - [ "$line" = "KITTY_DATA_END" ] && break; + while IFS= builtin read -r line; do + [ "$line" = "KITTY_DATA_END" ] && break data="$data$line" done [ -n "$data" -a "$started" != "done" ] && { builtin echo "Updating $ed_filename..." builtin printf "%s" "$data" | builtin command base64 -d > "$ed_filename" } - [ "$started" = "done" ] && break; + [ "$started" = "done" ] && break done }