From e48843b2de03d44db45dcdabc36acacdbe97e6ff Mon Sep 17 00:00:00 2001 From: Mori Zen <71zenith@proton.me> Date: Thu, 27 Feb 2025 01:26:27 +0530 Subject: [PATCH] fix: range selection (#1487) --- ani-cli | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ani-cli b/ani-cli index d926caf7..fb47d77f 100755 --- a/ani-cli +++ b/ani-cli @@ -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() {