From 43f6ef96a1c5de0226f11220616dbe719e4f03bb Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 6 Oct 2024 20:47:19 +0200 Subject: [PATCH] check length --- .config/fish/functions/latex-color.fish | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.config/fish/functions/latex-color.fish b/.config/fish/functions/latex-color.fish index c942822..4a5a885 100644 --- a/.config/fish/functions/latex-color.fish +++ b/.config/fish/functions/latex-color.fish @@ -18,6 +18,12 @@ function latex-color --description "Get the LaTeX color from HEX code" set hex (string sub -s 2 $hex) end + # Check if the length of the hex is valid + if not contains $(string length $hex) $(string split " " "3 4 6 8") + echo "Error: Invalid HEX code" + return 1 + end + # Expand 3 hex to 4 hex if test (string length $hex) -eq 3 set hex $(string join "" $hex 0)