@@ -705,11 +705,27 @@ survey_kernel_files() {
705705 local ser
706706 local file
707707 debug " Surveying Kernel files"
708- local do_not_delete
708+ local do_not_delete=()
709709 # set -x
710- mapfile -t do_not_delete < <( ls /boot/* rescue* /boot/* kdump* \
711- | sed -e ' s/\.x86_64kdump\.img//' \
712- | xargs -I% basename % 2> /dev/null || :)
710+ # Unfortunately, ls will exit non-zero if a listed glob is not found.
711+ # This is bad behavior when -o pipefail is set. This is why we are
712+ # splitting up this into tests.
713+
714+ if compgen -G " /boot/*rescue*" ; then
715+ mapfile -t -O " ${# do_not_delete[@]} " do_not_delete < <( ls /boot/* rescue* \
716+ | xargs -I% basename % )
717+ debug printf " a: %s\n" " ${do_not_delete[@]} "
718+ fi
719+
720+ if compgen -G " /boot/*kdump*" ; then
721+ mapfile -t -O " ${# do_not_delete[@]} " do_not_delete < <( ls /boot/* kdump* \
722+ | xargs -I% basename % \
723+ | sed -E ' s/\.x86_64kdump\.img//' )
724+ debug printf " b: %s\n" " ${do_not_delete[@]} "
725+ fi
726+
727+ debug printf " c: %s\n" " ${do_not_delete[@]} "
728+
713729 local dnd_grep=" | grep -F -v "
714730 # notice that we do not want to add quotes to the %s because the grep -F will
715731 # interpret them literally and not match the filename
@@ -742,10 +758,10 @@ survey_kernel_files() {
742758 local fiile
743759 for file in " ${kernel_files[@]} " ; do
744760 debug " kernel_file [$file ]"
745- [[ $file =~ /boot/initramfs* ]] && continue
746- [[ $file =~ * .fc* .x86_64 ]] && continue
761+ [[ $file = /boot/initramfs* ]] && continue
762+ [[ $file = * .fc* .x86_64 ]] && continue
747763 [[ $file = * initrd-plymouth.img ]] && continue
748- fiile=$( basename $file )
764+ fiile=$( basename " $file " )
749765 fiile=${fiile% .img}
750766
751767 if [[ $fiile =~ $booted ]]; then
@@ -762,9 +778,9 @@ survey_kernel_files() {
762778 fi
763779 done
764780 # sleep 2
765- local booted_ser=$( kernel_to_relnum $booted )
781+ local booted_ser=$( kernel_to_relnum " $booted " )
766782 if (( ${# kernel_sort_names[@]} > 0 )) ; then
767- declare -A ser_files
783+ # declare -A ser_files
768784 for file in " ${! kernel_sort_names[@]} " ; do
769785 ser=" ${kernel_sort_names[$file]} "
770786 done
0 commit comments