I gave unwind.conf(5) a read and wanted to test the following:

        $ echo preference dhcp | unwind -vnf-
        preference { DoT forwarder recursor dhcp stub }

First, I thought unwind had a parser bug and would ignore my preference,
but turns out it simply does not treat "-" as standard input.

Fair enough, using /dev/stdin works, but while playing around I found
that logging nonexistent config files would really help, so the following
diff does

        $ unwind -vnf/nonexistent                     
        preference { DoT forwarder recursor dhcp stub }

        $ ./obj/unwind -vnf/nonexistent
        /nonexistent: No such file or directory
        preference { DoT forwarder recursor dhcp stub }

With that, my initial case is no longer misleading;  alternatively, I
can implement the dash semantic, but that's another diff.

OK?


Index: parse.y
===================================================================
RCS file: /cvs/src/sbin/unwind/parse.y,v
retrieving revision 1.15
diff -u -p -r1.15 parse.y
--- parse.y     9 Nov 2019 16:28:10 -0000       1.15
+++ parse.y     18 Nov 2019 21:08:26 -0000
@@ -784,9 +784,9 @@ parse_config(char *filename)
 
        file = pushfile(filename, 0);
        if (file == NULL) {
+               log_warn("%s", filename);
                if (errno == ENOENT)    /* no config file is fine */
                        return (conf);
-               log_warn("%s", filename);
                free(conf);
                return (NULL);
        }

Reply via email to