diff --git a/CHANGELOG.md b/CHANGELOG.md index b2ca60035..be004f40b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,8 @@ Bugfixes: * Fix option `--title-fqdn` doesn't work (Title) * Fix used spaces calculation (Disk, Linux / BSD / macOS, #508) * Fix `--brightness-format` (Brightness) +* Fix specifying `--set-keyless` with the same key second time won't override the value set before (#517) +* Fix specifying `--color` second time won't clear the value set before (#517) Logo: * Change the special handling of `kitty` protocol with `.png` image file to a new image protocol `kitty-direct`. This is the fastest image protocol because fastfetch doesn't need to pre-encode the image to base64 or something and the image content doesn't need to be transmitted via tty. Note: diff --git a/src/common/option.c b/src/common/option.c index faae31619..dc4be709d 100644 --- a/src/common/option.c +++ b/src/common/option.c @@ -132,6 +132,7 @@ bool ffOptionParseBoolean(const char* str) void ffOptionParseColor(const char* value, FFstrbuf* buffer) { + ffStrbufClear(buffer); ffStrbufEnsureFree(buffer, 63); while(*value != '\0') diff --git a/src/fastfetch.c b/src/fastfetch.c index 874a799f0..8156b7244 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -861,10 +861,24 @@ static void parseOption(FFdata* data, const char* key, const char* value) fprintf(stderr, "Error: usage: %s =\n", key); exit(477); } - FFCustomValue* customValue = (FFCustomValue*) ffListAdd(&data->customValues); - ffStrbufInitS(&customValue->value, &customValueStr.chars[index + 1]); - ffStrbufSubstrBefore(&customValueStr, index); - ffStrbufInitMove(&customValue->key, &customValueStr); + + FF_STRBUF_AUTO_DESTROY customKey = ffStrbufCreateNS(index, customValueStr.chars); + + FFCustomValue* customValue = NULL; + FF_LIST_FOR_EACH(FFCustomValue, x, data->customValues) + { + if(ffStrbufEqual(&x->key, &customKey)) + { + ffStrbufDestroy(&x->key); + ffStrbufDestroy(&x->value); + customValue = x; + break; + } + } + if(!customValue) customValue = (FFCustomValue*) ffListAdd(&data->customValues); + ffStrbufInitMove(&customValue->key, &customKey); + ffStrbufSubstrAfter(&customValueStr, index); + ffStrbufInitMove(&customValue->value, &customValueStr); customValue->printKey = *subkey == '\0'; }