When selecting an invalid named color for the text (either with --color or in the config file), it gets added to the affected text minus its first letter plus a 'm' (i.e., "fastfetch --color yello" would prepend "ello"). Sometimes, even numbers and other symbols are added
This is a rather trivial bug (only extra characters being added)
What happened:
(Screenshots below)
I first tried to change the color of both the title and keys with
fastfetch --color purple
which, obviously, does not work, since ANSI does not have a "purple" color, but rather "magenta". The thing is, "urplem" was prepended to both the title and the keys, which should not have happened. The output remained correct, though.
Testing with different named colors (with or without prefix) gave the same result: valid colors worked, invalid named colors had their name prepended to the text minus their first letter plus a 'm', which was curious.
What should happen:
No characters should be prepended. The color of the affected text should (probably) be set instead to the one in the configuration file, or the default one
Fastfetch version used:
2.20.0, which is the latest version
Did it work in an older version:
I can't tell for certain, since I've only started using fastfetch very recently.
I did pick an old version from the releases page (more specifically, 2.8.3), and the bug still remained
Where did you get the binary:
Compiled both from the master and dev branch, with both having this bug
Does this issue still occur in the latest dev build:
Yes
Screenshots:
Valid named color (magenta):
Invalid named color (magent and purple):
The content of the configuration file you use (if any):
and similar commands don't work anymore, so that line seems essential. After some experiments, I arrived to another solution: check if value has a number and, if so, execute the line mentioned above. This seemed to work - applying invalid name colors no longer adds extra characters and ANSI escape sequences (like 35; 5; 38:) work again. The same goes for the values in the configuration file
In order to accomplish this, I used a regex ("[0-9]"), which would require importing another library which may not be great. A for loop could be used instead. Of course, this would mean the value can be iterated several times, though I haven't noticed any difference in the performance
Sorry for writing a whole dissertation just for a trivial bug. Since I came up with a potential solution, should I create a pull request with it? I'm not used to contributing to open source
General description:
When selecting an invalid named color for the text (either with --color or in the config file), it gets added to the affected text minus its first letter plus a 'm' (i.e., "fastfetch --color yello" would prepend "ello"). Sometimes, even numbers and other symbols are added This is a rather trivial bug (only extra characters being added)
What happened:
(Screenshots below) I first tried to change the color of both the title and keys with
which, obviously, does not work, since ANSI does not have a "purple" color, but rather "magenta". The thing is, "urplem" was prepended to both the title and the keys, which should not have happened. The output remained correct, though.
Testing with different named colors (with or without prefix) gave the same result: valid colors worked, invalid named colors had their name prepended to the text minus their first letter plus a 'm', which was curious.
What should happen:
No characters should be prepended. The color of the affected text should (probably) be set instead to the one in the configuration file, or the default one
Fastfetch version used:
2.20.0, which is the latest version
Did it work in an older version:
I can't tell for certain, since I've only started using fastfetch very recently.
I did pick an old version from the releases page (more specifically, 2.8.3), and the bug still remained
Where did you get the binary:
Compiled both from the master and dev branch, with both having this bug
Does this issue still occur in the latest dev build:
Yes
Screenshots:
Valid named color (magenta):
Invalid named color (magent and purple):
The content of the configuration file you use (if any):
Output of `fastfetch -c ci.jsonc --format json (with unnecessary or sensitive information removed):
Output of
fastfetch --list-features
:Possible solution
After searching around in the code, I found what I believe is the problem
Line 210 in the file src/common/option.c
After commenting out this line and recompiling, using commands like:
doesn't prepend extra characters. However,
and similar commands don't work anymore, so that line seems essential. After some experiments, I arrived to another solution: check if value has a number and, if so, execute the line mentioned above. This seemed to work - applying invalid name colors no longer adds extra characters and ANSI escape sequences (like 35; 5; 38:) work again. The same goes for the values in the configuration file
In order to accomplish this, I used a regex ("[0-9]"), which would require importing another library which may not be great. A for loop could be used instead. Of course, this would mean the value can be iterated several times, though I haven't noticed any difference in the performance
Sorry for writing a whole dissertation just for a trivial bug. Since I came up with a potential solution, should I create a pull request with it? I'm not used to contributing to open source