system-image: improve comments and minor change to user message

master
Jan Danielzick 2025-01-17 11:52:54 +01:00
parent c1c2a8239c
commit 4b6926c004
1 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# used to work around cases where stdin is unavailable or not a terminal
# work around situations where stdin is unavailable or not a terminal
if bash -c ': > /dev/tty' > /dev/null 2>&1; then
TTY_OR_CONSOLE="/dev/tty"
else
@ -22,10 +22,12 @@ function yesno {
read -p "[y/n] " -n1 DISCARD_ME < $TTY_OR_CONSOLE > $TTY_OR_CONSOLE
case "$DISCARD_ME" in
y)
# add a line break
echo_tty
return 0
;;
n)
# add a line break
echo_tty
return 1
;;
@ -44,7 +46,10 @@ if [ "$1" = "--yes" ]; then
else
DONT_ASK="false"
#TODO: use a bright color for ==== and the question
echo_tty "=========================="
echo_tty "Create a new system image?"
echo_tty "=========================="
echo_tty
echo_tty "This will replace the existing system image with a snapshot of the currently"
echo_tty "running system. Choosing no here will discard any newly installed programs,"
@ -57,8 +62,6 @@ else
echo_tty
fi
#TODO: colors (bright white / light gray for readability)
if $DONT_ASK || yesno; then
echo_tty -n "Generating exclusion list... "
# cutting off the leading slash allows us to just ignore empty lines below
@ -68,6 +71,7 @@ if $DONT_ASK || yesno; then
for I in ${!MOUNT_LIST[@]}; do
if [ ! -z "${MOUNT_LIST[$I]}" ]; then
# check if a parent of ${MOUNT_LIST[$I]} is already in $EXCLUDE_LIST
FOUND=0
for J in ${!EXCLUDE_LIST[@]}; do
if grep "${EXCLUDE_LIST[$J]}" > /dev/null <<< "${MOUNT_LIST[$I]}"; then