Monday, October 31, 2022

Re: unexpected behavior from neofetch in snapshots

On 2022/10/31 11:54:10 -0400, Norvell Spearman <norvell.spearman@gmail.com> wrote:
> There seems to be a problem between neofetch and bash in snapshots.
> neofetch displays the ASCII logo for the OS and most of the expected
> information about the system it's running on, but stops then shows the
> next command prompt in the middle of the logo, leaving out the usual
> colored blocks. With 7.2-release and earlier I got behavior as seen in
> expected.png. With 7.2-current I get behavior as seen in current.png.
> Running "neofetch -v" shows the following error:
>
> /usr/local/bin/neofetch: line 3802: bad substitution: no closing `}' in ${block_spaces// /${blocks}nl}
>
> 7.2-release uses bash-5.1.16 while -current uses bash-5.2.2 (with the
> same version of neofetch in both), so I'm guessing that something
> changed with bash between the two versions. I don't know much about
> shell scripting, so all apologies for not being more helpful.
>
> To show the expected behavior, I downloaded the -release version of bash
> (5.1.16), renamed its binary, and told a copy of -current's neofetch to
> use the renamed bash for execution.
>
> Let me know if you need more information. I did check marc.info to see
> whether anybody else had already reported this, so apologies in advance
> if I missed something.

There's an issue about this opened on github:
https://github.com/dylanaraps/neofetch/issues/2209

This is a bit out of my comfort zone, I don't really know what the
bash // parameter substitution does, but as was hinted by a user in
that issue escaping the [ fixes it, at least in my brief testing.

(no idea how the raw escape in the diff will end up in the mail)

Index: Makefile
===================================================================
RCS file: /home/cvs/ports/sysutils/neofetch/Makefile,v
retrieving revision 1.11
diff -u -p -r1.11 Makefile
--- Makefile 11 Mar 2022 19:57:43 -0000 1.11
+++ Makefile 31 Oct 2022 16:21:37 -0000
@@ -4,7 +4,7 @@ CATEGORIES = sysutils misc
GH_ACCOUNT = dylanaraps
GH_PROJECT = neofetch
GH_TAGNAME = 7.1.0
-REVISION = 0
+REVISION = 1

# MIT
PERMIT_PACKAGE = Yes
Index: patches/patch-neofetch
===================================================================
RCS file: /home/cvs/ports/sysutils/neofetch/patches/patch-neofetch,v
retrieving revision 1.8
diff -u -p -r1.8 patch-neofetch
--- patches/patch-neofetch 11 Mar 2022 19:57:43 -0000 1.8
+++ patches/patch-neofetch 31 Oct 2022 16:21:31 -0000
@@ -1,4 +1,5 @@
From https://github.com/dylanaraps/neofetch/pull/1494
+and add needed escape to please bash.

Index: neofetch
--- neofetch.orig
@@ -22,3 +23,14 @@ Index: neofetch
gpu="${gpu/OpenGL renderer string: }"
;;
esac
+@@ -3800,8 +3799,8 @@ 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}"
++ [[ "$blocks" ]] && cols+="${block_spaces// /${blocks}\[mnl}"
++ [[ "$blocks2" ]] && cols+="${block_spaces// /${blocks2}\[mnl}"
+
+ # Add newlines to the string.
+ cols=${cols%%nl}

No comments:

Post a Comment