From 0271b270ee2b33b346d05613d1c06ad1fb2eee00 Mon Sep 17 00:00:00 2001 From: NRK Date: Tue, 13 Apr 2021 23:02:55 +0600 Subject: [PATCH] remove list by line num why the fuck would anyone want to list a specific line. makes no sense. search via title/tag like a normal human bean! --- sxbm | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/sxbm b/sxbm index 6cbfd23..2f314d8 100755 --- a/sxbm +++ b/sxbm @@ -68,30 +68,18 @@ bm_list(){ esac done - expr "$1" : '[0-9]' > /dev/null && - local QUERY_LINE="$1" || - while [ -n "$1" ]; do - case "$1" in - +*) - local QUERY_TAG="${QUERY_TAG}$1 " - shift - ;; - *) - local QUERY_TITLE="${QUERY_TITLE}$1 " - shift - ;; - esac - done - - [ -n "$QUERY_LINE" ] && - [ $QUERY_LINE -gt $(wc -l < "$DATA_FILE") ] && - die "$QUERY_LINE doesn't exist. Use 'sxbm ls' to list all bookmark" || - awk -v COL_LINK="$COL_LINK" -v COL_TITLE="$COL_TITLE" \ - -v COL_LINE_NUM=$COL_LINE_NUM -v QUERY_LINE="$QUERY_LINE" \ - ' NR == QUERY_LINE { LINK=$1; $1=""; - gsub(/+\w+/,""); - print COL_LINE_NUM NR ") " COL_LINK LINK " " COL_TITLE $0 ; }' \ - "$DATA_FILE" + while [ -n "$1" ]; do + case "$1" in + +*) + local QUERY_TAG="${QUERY_TAG}$1 " + shift + ;; + *) + local QUERY_TITLE="${QUERY_TITLE}$1 " + shift + ;; + esac + done # POSIX shell doesn't have arrays. # Desperate times calls for desperate measures!