This fixes a bug introduced by unreleased commit 38aaf5e61 (all: quote
more user originated strings, 2026-10-23):

    $ printf 'TERM *\nUNRECOGNIZED 1\n' >f
    $ dircolors -b f
    dircolors: f:2: unrecognized keyword f
    $ ./src/dircolors -b f
    dircolors: f:2: unrecognized keyword 'UNRECOGNIZED'

* src/dircolors.c (dc_parse_stream): Use quote_n and specify slot 1
instead of reusing slot 0.
* tests/misc/dircolors.pl (@Tests): Add a test case for this error
message.
---
 src/dircolors.c         | 2 +-
 tests/misc/dircolors.pl | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/dircolors.c b/src/dircolors.c
index b7b1c72da..9cdc309d0 100644
--- a/src/dircolors.c
+++ b/src/dircolors.c
@@ -408,7 +408,7 @@ dc_parse_stream (FILE *fp, char const *filename)
         {
           error (0, 0, _("%s:%td: unrecognized keyword %s"),
                  (filename ? quotef (filename) : _("<internal>")),
-                 line_number, quote (keywd));
+                 line_number, quote_n (1, keywd));
           ok = false;
         }
 
diff --git a/tests/misc/dircolors.pl b/tests/misc/dircolors.pl
index d58d9dd22..9abe35869 100755
--- a/tests/misc/dircolors.pl
+++ b/tests/misc/dircolors.pl
@@ -72,6 +72,10 @@ my @Tests =
               "Try 'dircolors --help' for more information.\n"},
       {EXIT => 1}],
 
+     ['unrecognized-1', '-b', {IN => {f => "TERM *\nUNRECOGNIZED 1\n"}},
+      {ERR => "dircolors: f:2: unrecognized keyword 'UNRECOGNIZED'\n"},
+      {EXIT => 1}],
+
      ['print-ls-colors', '--print-ls-colors', {IN => "OWT 40;33\n"},
       {OUT => "\x1B[40;33mtw\t40;33\x1B[0m\n"}],
 
-- 
2.56.1


Reply via email to