Package: neofetch
Version: 7.1.0-4
Severity: normal
Tags: patch upstream

Dear Maintainer,

I found that installing and using neofetch on Debian testing (bookworm),
it had different behavior than that on stable (bullseye). Namely, the
color block output using the default configuration (via the `info cols`
directive) does not work correctly. Instead of printing a grid of
terminal colors, it exits early due to a syntax error in bash 5.2 and
can cause the terminal prompt to overlap the distribution logo.

Running `neofetch -v` with the default config gives the following
output:

```
$ neofetch -v
       _,met$$$$$gg.          nightfirecat@debian
    ,g$$$$$$$$$$$$$$$P.       -------------------
  ,g$$P"     """Y$$.".        OS: Debian GNU/Linux bookworm/sid x86_64
 ,$$P'              `$$$.     Host: Laptop (12th Gen Intel Core) A6
',$$P       ,ggs.     `$$b:   Kernel: 6.0.0-6-amd64
`d$$'     ,$P"'   .    $$$    Uptime: 37 mins
 $$P      d$'     ,    $$P    Packages: 2697 (dpkg), 12 (flatpak)
 $$:      $$.   -    ,d$$'    Shell: bash 5.2.2
 $$;      Y$b._   _,d$P'      Resolution: 2256x1504
 Y$$.    `.`"Y$$$$P"'         DE: Plasma 5.26.4
 `$$b      "-.__              WM: KWin
grep: /etc/gtk-2.0/gtkrc: No such file or directory
   `Y$$.                      Theme: Breeze [Plasma], Breeze [GTK2/3]
grep: /etc/gtk-2.0/gtkrc: No such file or directory
       `Y$$b.                 Icons: [Plasma], candy-icons [GTK2/3]
          `"Y$b._             Terminal: konsole
qtpaths: could not find a Qt installation of ''
/usr/bin/neofetch: line 2110: /sys/devices/system/cpu/cpu0/cpufreq/bios_limit: 
No sucy
/usr/bin/neofetch: line 2111: /sys/devices/system/cpu/cpu0/cpufreq/bios_limit: 
No sucy
                              CPU: 12th Gen Intel i7-1260P (16) @ 4.700GHz
                              GPU: Intel Alder Lake-P
                              Memory: 4745MiB / 15714MiB
/usr/bin/neofetch: line 3803: bad substitution: no closing `}' in 
${block_spaces// /$}
```

And running `neofetch` [using my own config][1], I get this output:
(prompt is not part of neofetch; it merely overlaps it)

```
$ neofetch
       _,met$$$$$gg.          nightfirecat@debian.framework 
    ,g$$$$$$$$$$$$$$$P.       ----------------------------- 
  ,g$$P"     """Y$$.".        OS: Debian GNU/Linux bookworm/sid x86_64 
 ,$$P'              `$$$.     Kernel: Linux 6.0.0-6-amd64 
',$$P       ,ggs.     `$$b:   Uptime: 9 mins 
`d$$'     ,$P"'   .    $$$    Packages: 2697 (dpkg), 12 (flatpak) 
 $$P      d$'     ,    $$P    Shell: bash 5.2.2 
 $$:      $$.   -    ,d$$'    DE: Plasma 5.26.4 
 $$;      Y$b._   _,d$P'      WM: KWin 
 Y$$.    `.`"Y$$$$P"'         Theme: Breeze [Plasma], Breeze [GTK2/3] 
 `$$b      "-.__              Icons: [Plasma], candy-icons [GTK2/3] 
  `Y$$                        CPU: 12th Gen Intel i7-1260P (16) @ 4.7GHz 
   `Y$$.                      Memory: 3.63GiB / 15.35GiB (23%) 
     `$$b.                    Disk (/): 31G / 914G (4%) 
       `Y$$b.
[nightfirecat@debian.framework ~]
$             `"""
```

This bug has been [reported upstream][2], though no fix has been merged
due to apparent inactivity on the project. I found that [applying a
patch from a fork of the project][3] fixes the issue neatly without
causing regression for older bash versions. The following diff, adapted
from said patch, fixes the issue for me:

```
diff --git a/neofetch b/neofetch
index 1e4b564..effa048 100755
--- a/neofetch
+++ b/neofetch
@@ -3800,8 +3800,13 @@ get_cols() {
         printf -v block_spaces "%${block_height}s"

         # Convert the spaces into rows of blocks.
-        [[ "$blocks"  ]] && cols+="${block_spaces// /${blocks}nl}"
-        [[ "$blocks2" ]] && cols+="${block_spaces// /${blocks2}nl}"
+        if [[ $BASH_VERSION == 3* ]]; then
+            [[ "$blocks"  ]] && cols+="${block_spaces// /${blocks}nl}"
+            [[ "$blocks2" ]] && cols+="${block_spaces// /${blocks2}nl}"
+        else
+            [[ "$blocks"  ]] && cols+="${block_spaces// /${blocks}\[mnl}"
+            [[ "$blocks2" ]] && cols+="${block_spaces// /${blocks2}\[mnl}"
+        fi

         # Add newlines to the string.
         cols=${cols%%nl}
```

Thanks,
Jordan

[1]: 
https://git.nightfirec.at/nightfirecat/dotfiles/src/commit/91ac846246fab70a99336169058d6ba301b6e538/src/.neofetch.config.json
[2]: https://github.com/dylanaraps/neofetch/issues/2195
[3]: https://github.com/hykilpikonna/hyfetch/pull/24#issuecomment-1296304767

-- System Information:
Debian Release: bookworm/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.0.0-6-amd64 (SMP w/16 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

neofetch depends on no packages.

Versions of packages neofetch recommends:
ii  caca-utils                       0.99.beta20-3
ii  chafa                            1.12.4-1
ii  imagemagick                      8:6.9.11.60+dfsg-1.3+b4
ii  imagemagick-6.q16 [imagemagick]  8:6.9.11.60+dfsg-1.3+b4
ii  jp2a                             1.1.1-2
ii  libsixel-bin                     1.10.3-3
ii  pciutils                         1:3.9.0-2
ii  w3m-img                          0.5.3+git20220429-1+b1

neofetch suggests no packages.

-- no debconf information

Reply via email to