From 1cfa3ee4c7c1741fca3cd26fb13451621d14bbf2 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 30 Oct 2023 00:05:20 +0900 Subject: [PATCH] fzf-preview.sh: Check the number of arguments --- bin/fzf-preview.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/fzf-preview.sh b/bin/fzf-preview.sh index bd12e3b..1818f04 100755 --- a/bin/fzf-preview.sh +++ b/bin/fzf-preview.sh @@ -7,7 +7,12 @@ # - https://github.com/hpjansson/chafa # - https://github.com/sharkdp/bat -file=$1 +if [[ $# -ne 1 ]]; then + >&2 echo "usage: $0 FILENAME" + exit 1 +fi + +file=${1/#\~\//$HOME/} type=$(file --mime-type "$file") if [[ ! $type =~ image/ ]]; then