mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Use zsh's builtin stat instead of relying on the stat command
This commit is contained in:
@@ -455,13 +455,11 @@ edit-in-kitty() {
|
|||||||
builtin echo "$ed_filename is not a file" > /dev/stderr
|
builtin echo "$ed_filename is not a file" > /dev/stderr
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
builtin local stat_result=""
|
builtin zmodload -F zsh/stat b:zstat
|
||||||
stat_result=$(builtin command stat -L --format '%d:%i:%s' "$ed_filename" 2> /dev/null)
|
builtin typeset -A stat_result
|
||||||
[ $? != 0 ] && stat_result=$(builtin command stat -L -f '%d:%i:%z' "$ed_filename" 2> /dev/null)
|
builtin zstat -H stat_result "$ed_filename" || { builtin echo "Failed to stat the file: $ed_filename" > /dev/stderr; return 1; }
|
||||||
[ -z "$stat_result" ] && { builtin echo "Failed to stat the file: $ed_filename" > /dev/stderr; return 1; }
|
[ "${stat_result[size]}" -gt $((8 * 1024 * 1024)) ] && { builtin echo "File is too large for performant editing"; return 1; }
|
||||||
data="$data,file_inode=$stat_result"
|
data="$data,file_inode=${stat_result[device]}:${stat_result[inode]}:${stat_result[size]}"
|
||||||
builtin local file_size=$(builtin echo "$stat_result" | builtin command cut -d: -f3)
|
|
||||||
[ "$file_size" -gt $((8 * 1024 * 1024)) ] && { builtin echo "File is too large for performant editing"; return 1; }
|
|
||||||
data="$data,file_data=$(builtin command cat "$ed_filename" | builtin command base64)"
|
data="$data,file_data=$(builtin command cat "$ed_filename" | builtin command base64)"
|
||||||
_ksi_transmit_data "$data" "edit"
|
_ksi_transmit_data "$data" "edit"
|
||||||
data=""
|
data=""
|
||||||
|
|||||||
Reference in New Issue
Block a user