@@ -44,12 +44,21 @@ grub_btrfs_config="${sysconfdir}/default/grub-btrfs/config"
4444[ -f " $grub_btrfs_config " ] && . " $grub_btrfs_config "
4545[ -f " ${sysconfdir} /default/grub" ] && . " ${sysconfdir} /default/grub"
4646
47- # # Error Handling
47+ # # Logging
48+ print_info ()
49+ {
50+ printf " grub-btrfs: %s\n" " $* " >&2
51+ }
52+
53+ print_warning ()
54+ {
55+ printf " grub-btrfs: Warning: %s\n" " $* " >&2
56+ }
57+
4858print_error ()
4959{
50- local err_msg=" $* "
5160 local bug_report=" If you think an error has occurred, please file a bug report at \" https://github.com/Antynea/grub-btrfs\" "
52- printf " %s\n" " ${err_msg} " " ${bug_report} " >&2 ;
61+ printf " grub-btrfs: Error: %s\n" " $* " " ${bug_report} " >&2
5362 exit 0
5463}
5564
@@ -75,10 +84,10 @@ while getopts :V-: opt; do
7584done
7685
7786# # Exit the script, if:
78- [ " $( echo " $GRUB_BTRFS_DISABLE " | tr ' [:upper:]' ' [:lower:]' ) " = ' true' ] && print_error " GRUB_BTRFS_DISABLE is set to true (default=false)"
79- if ! type btrfs > /dev/null 2>&1 ; then print_error " btrfs-progs isn't installed" ; fi
87+ [ " $( echo " $GRUB_BTRFS_DISABLE " | tr ' [:upper:]' ' [:lower:]' ) " = ' true' ] && { print_info " GRUB_BTRFS_DISABLE is set to true (default=false)" ; exit 0 ; }
88+ if ! type btrfs > /dev/null 2>&1 ; then print_info " btrfs-progs isn't installed" ; exit 0 ; fi
8089[ -f " ${GRUB_BTRFS_MKCONFIG_LIB:-/ usr/ share/ grub/ grub-mkconfig_lib} " ] && . " ${GRUB_BTRFS_MKCONFIG_LIB:-/ usr/ share/ grub/ grub-mkconfig_lib} " || print_error " grub-mkconfig_lib couldn't be found"
81- [[ " $( btrfs filesystem df / 2>&1 ) " == * " not a btrfs filesystem" * ]] && print_error " Root filesystem isn't btrfs"
90+ [[ " $( btrfs filesystem df / 2>&1 ) " == * " not a btrfs filesystem" * ]] && { print_info " Root filesystem isn't btrfs" ; exit 0 ; }
8291
8392printf " Detecting snapshots ...\n" >&2 ;
8493
686695# if no snapshot found, delete the "$grub_btrfs_directory/grub-btrfs.new" file and the "$grub_btrfs_directory/grub-btrfs.cfg.bkp" file and exit
687696if [ " ${count_limit_snap} " = " 0" ] || [ -z " ${count_limit_snap} " ]; then
688697 rm -f " $grub_btrfs_directory /grub-btrfs.new" " $grub_btrfs_directory /grub-btrfs.cfg.bkp"
689- print_error " No snapshots found."
698+ print_info " No snapshots found." ; exit 0
690699fi
691700# Move "grub-btrfs.new" to "grub-btrfs.cfg"
692701header_menu
0 commit comments