mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-19 06:54:58 +02:00
Use head -c only if available
This commit is contained in:
@@ -94,12 +94,18 @@ else
|
|||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
read_n_bytes_from_tty() {
|
# using dd with bs=1 is very slow, so use head. On non GNU coreutils head
|
||||||
# using dd with bs=1 is very slow, so use head. On non GNU coreutils head
|
# does not limit itself to reading -c bytes only from the pipe so we can potentially lose
|
||||||
# does not limit itself to reading -c bytes only from the pipe so we can potentially lose
|
# some trailing data, for instance if the user starts typing. Cant be helped.
|
||||||
# some trailing data, for instance if the user starts typing. Cant be helped.
|
if [ "$(printf "%s" "test" | command head -c 3 2> /dev/null)" = "tes" ]; then
|
||||||
command head -c "$1" < /dev/tty
|
read_n_bytes_from_tty() {
|
||||||
}
|
command head -c "$1" < /dev/tty
|
||||||
|
}
|
||||||
|
else
|
||||||
|
read_n_bytes_from_tty() {
|
||||||
|
command dd bs=1 count="$1" < /dev/tty 2> /dev/null
|
||||||
|
}
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
debug() { dcs_to_kitty "print" "debug: $1"; }
|
debug() { dcs_to_kitty "print" "debug: $1"; }
|
||||||
|
|||||||
Reference in New Issue
Block a user