From f0c50d1d76ff88593a9c0e340acd7c93a201f9d9 Mon Sep 17 00:00:00 2001
From: Antynea <froubeyrie@gmail.com>
Date: Fri, 22 Apr 2016 15:29:38 +0200
Subject: [PATCH] Fix : GRUB_BTRFS_LIMIT (Limit the number of snapshots
 populated in the GRUB menu.)

Fix : When a value =< 0, script stop correctly
fix : When a value => 1, script stop when the value is reached

e.g :
 - GRUB_BTRFS_LIMIT="0"
   script doesn't detect snapshot

 - GRUB_BTRFS_LIMIT"1" or "2" "etc..."
   script will stop the snapshot detection when value is reached
---
 41_snapshots-btrfs | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs
index 3ff4cc0..8c66ec0 100644
--- a/41_snapshots-btrfs
+++ b/41_snapshots-btrfs
@@ -274,6 +274,8 @@ list_kernels_initramfs()
 	IFS=$'\n'
 	count_limit_snap=0
 	for item in $(snapshot_list); do
+		### fix: limit_snap_show=0
+		[[ ${limit_snap_show} -le 0 ]] && break;
 		IFS=$oldIFS
 		item=($item)
 		snap_dir_name=${item[@]:2:${#item[@]}}
@@ -314,11 +316,9 @@ list_kernels_initramfs()
 		title_format
 		# echo "${title_menu[*]}"
 		snapshots_entry
-	### Limit snapshots found during run "grub-mkconfig"
-        count_limit_snap=$((1+$count_limit_snap))
-        if [[ $count_limit_snap -gt $limit_snap_show ]]; then
-            break;
-        fi
+		### Limit snapshots found during run "grub-mkconfig"
+	        count_limit_snap=$((1+$count_limit_snap))
+	        [[ $count_limit_snap -ge $limit_snap_show ]] && break;
 	done
 	IFS=$oldIFS
 }