home · contact · privacy
Fix.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 6 May 2025 03:05:52 +0000 (05:05 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 6 May 2025 03:05:52 +0000 (05:05 +0200)
bookworm/scripts/lib/apt_get_digested

index 49a30c6c93fd39d041446f9180a5618d3f877478..67cbccb34ca7bdbdef6199d3469d331d99fe02d7 100644 (file)
@@ -3,8 +3,10 @@
 
 apt_get_digested() {
 prefixed_msg_init 'apt_get_digested'
+
 abort_if_command_unknown calc
 
+_FINISH_LINE='apt_get_digested_FINISH_LINE'
 _SEDS=\
 '|\(Reading database \.\.\. .*|IGNORE
 |Generation complete.|IGNORE
@@ -29,21 +31,15 @@ BECOME_NEXT_PREFIX|dpkg: ([[:print:]]+): dependency problems, but removing anywa
 dpkg warns: unable to delete old directories (not empty):|dpkg: warning: unable to delete old directory '"'"'([[:print:]]+)'"'"': Directory not empty|\1
 update-alternatives: providing in auto mode:|update-alternatives: using ([[:print:]]+) to provide ([[:print:]]+) \(([[:print:]]+)\) in auto mode| [\1 → \2 (\3)]'
 
-_FINISH_LINE='apt_get_digested_FINISH_LINE'
 _LAST_PREFIX=''
 _STARTED_PRINTING=
-print_cr_and_if_started_printing_nl() {
-    if [ ! -z "${_STARTED_PRINTING}" ]; then
-        printf '\n'
-    fi
-    printf '\r'
-}
 eval "DEBIAN_FRONTEND=noninteractive apt-get -y $1; echo ${_FINISH_LINE}" 2>&1 | while read _LINE; do
     _LINE=$(printf '%s' "${_LINE}" | tr -d '\r')
     if [ -z "${_LINE}" ]; then
         continue
     elif [ "${_LINE}" = "${_FINISH_LINE}" ]; then
-        print_cr_and_if_started_printing_nl()
+        test ! -z "${_STARTED_PRINTING}" && printf '\n'
+        printf '\r'
         break
     fi
     _COMPRESSED_ITEM=''
@@ -66,12 +62,13 @@ eval "DEBIAN_FRONTEND=noninteractive apt-get -y $1; echo ${_FINISH_LINE}" 2>&1 |
     if [ "${_COMPRESSED_ITEM}" = "IGNORE" ]; then
         continue
     elif [ -z "${_COMPRESSED_ITEM}" ]; then
-        print_cr_and_if_started_printing_nl()
-        printf '%s' "${_LINE}"
+        test ! -z "${_STARTED_PRINTING}" && printf '\n'
+        printf '\r%s' "${_LINE}"
         _LAST_PREFIX=''
     else
         if [ "${_PREFIX}" != "${_LAST_PREFIX}" ]; then
-            print_cr_and_if_started_printing_nl()
+            test ! -z "${_STARTED_PRINTING}" && printf '\n'
+            printf '\r'
             prefixed_msg_no_nl "${_PREFIX}"
             _LAST_PREFIX="${_PREFIX}"
         fi