fix: range selection (#1487)

This commit is contained in:
Mori Zen 2025-02-27 01:26:27 +05:30 committed by GitHub
parent 709db81d4b
commit e48843b2de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

11
ani-cli
View File

@ -1,6 +1,6 @@
#!/bin/sh
version_number="4.9.7"
version_number="4.9.8"
# UI
@ -23,7 +23,14 @@ nth() {
multi_flag=""
[ $# -ne 1 ] && shift && multi_flag="$1"
line=$(printf "%s" "$stdin" | cut -f1,3 | tr '\t' ' ' | launcher "$multi_flag" "$prompt" | cut -d " " -f 1)
[ -n "$line" ] && printf "%s" "$stdin" | grep -E '^'"${line}"'($|[[:space:]])' | cut -f2,3 || exit 1
line_start=$(printf "%s" "$line" | head -n1)
line_end=$(printf "%s" "$line" | tail -n1)
[ -n "$line" ] || exit 1
if [ -z "$multi_flag" ]; then
printf "%s" "$stdin" | grep -E '^'"${line}"'($|[[:space:]])' | cut -f2,3 || exit 1
else
printf "%s" "$stdin" | sed -n '/^'"${line_start}"'$/,/^'"${line_end}$"'/p' || exit 1
fi
}
die() {