mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-13 03:01:32 +01:00
perf: remove forks, use read builtin
This commit is contained in:
parent
b5349dc137
commit
9a6401fce1
1 changed files with 2 additions and 3 deletions
|
|
@ -96,8 +96,7 @@ function _omz_async_request {
|
||||||
command true
|
command true
|
||||||
|
|
||||||
# Save the PID from the handler child process
|
# Save the PID from the handler child process
|
||||||
read pid <&$fd
|
read -u $fd "_OMZ_ASYNC_PIDS[$handler]"
|
||||||
_OMZ_ASYNC_PIDS[$handler]=$pid
|
|
||||||
|
|
||||||
# When the fd is readable, call the response handler
|
# When the fd is readable, call the response handler
|
||||||
zle -F "$fd" _omz_async_callback
|
zle -F "$fd" _omz_async_callback
|
||||||
|
|
@ -119,7 +118,7 @@ function _omz_async_callback() {
|
||||||
local old_output="${_OMZ_ASYNC_OUTPUT[$handler]}"
|
local old_output="${_OMZ_ASYNC_OUTPUT[$handler]}"
|
||||||
|
|
||||||
# Read output from fd
|
# 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
|
# Repaint prompt if output has changed
|
||||||
if [[ "$old_output" != "${_OMZ_ASYNC_OUTPUT[$handler]}" ]]; then
|
if [[ "$old_output" != "${_OMZ_ASYNC_OUTPUT[$handler]}" ]]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue