From 9a6401fce1e331ec5dd7667081c621f78068b75f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 3 Apr 2024 19:34:07 +0200 Subject: [PATCH] perf: remove forks, use read builtin --- lib/async_prompt.zsh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/async_prompt.zsh b/lib/async_prompt.zsh index 97b3c58eb..ac95bcd73 100644 --- a/lib/async_prompt.zsh +++ b/lib/async_prompt.zsh @@ -96,8 +96,7 @@ function _omz_async_request { command true # Save the PID from the handler child process - read pid <&$fd - _OMZ_ASYNC_PIDS[$handler]=$pid + read -u $fd "_OMZ_ASYNC_PIDS[$handler]" # When the fd is readable, call the response handler zle -F "$fd" _omz_async_callback @@ -119,7 +118,7 @@ function _omz_async_callback() { local old_output="${_OMZ_ASYNC_OUTPUT[$handler]}" # Read output from fd - _OMZ_ASYNC_OUTPUT[$handler]="$(cat <&$fd)" + IFS= read -r -u $fd -d '' "_OMZ_ASYNC_OUTPUT[$handler]" # Repaint prompt if output has changed if [[ "$old_output" != "${_OMZ_ASYNC_OUTPUT[$handler]}" ]]; then