check length

This commit is contained in:
Mylloon 2024-10-06 20:47:19 +02:00
parent 7f22c025ab
commit 43f6ef96a1
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -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)