From c6a5f6efb434fa64f31b40f366e7fecae80758e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 16 Aug 2015 22:30:56 +0200 Subject: [PATCH] Check that list_size value is not zero before division --- plugins/emoji/emoji.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/emoji/emoji.plugin.zsh b/plugins/emoji/emoji.plugin.zsh index adb11bb5..f2d169bf 100644 --- a/plugins/emoji/emoji.plugin.zsh +++ b/plugins/emoji/emoji.plugin.zsh @@ -257,7 +257,8 @@ function random_emoji() { else names=(${=emoji_groups[$group]}) fi - local list_size=$#names + local list_size=${#names} + [[ $list_size -eq 0 ]] && return 1 local random_index=$(( ( RANDOM % $list_size ) + 1 )) local name=${names[$random_index]} echo ${emoji[$name]}