diff --git a/remove-old-kernels b/remove-old-kernels index 486a7fc..4f193ad 100755 --- a/remove-old-kernels +++ b/remove-old-kernels @@ -39,7 +39,7 @@ show_help() cat <&2 "${RED}Warning: This program requires root privileges.$NORM" fi +echo -n "Confirm" ${dryrun:+--dry-run} "uninstall action for $phrase [Y/n]? " +if [ -n "$force" ]; then + echo "yes" +else + while true; do + read -r || { echo "Aborting"; exit 1; } + shopt -s nocasematch + case "$REPLY" in + n|no|q) exit 0 ;; + y|ye|yes|'') break ;; + *) ;; + esac + echo -n "[Y/n] " + shopt -u nocasematch + done +fi + + # shellcheck disable=SC2086 -V apt-get $force $dryrun remove $apt_args_list +V apt-get -y $dryrun remove $apt_args_list # Mask non-zero apt exit code on dry run: if [ -n "$dryrun" ]; then