[hackers] [sbase] getconf: Report invalid variables as errors || Michael Forney

From: <git_AT_suckless.org>
Date: Mon, 4 Sep 2017 02:46:20 +0200 (CEST)

commit c225d88d49f5cfd3c6e562700131cc7006d6d57a
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Sun Sep 3 15:39:47 2017 -0700
Commit: Michael Forney <mforney_AT_mforney.org>
CommitDate: Sun Sep 3 17:23:28 2017 -0700

    getconf: Report invalid variables as errors
    
    Printing `undefined` to stdout means that the variable is valid but not
    set. Instead, report an error in this case.
    
    linux 4.13 appends the result of `getconf LFS_CFLAGS` to HOSTCFLAGS,
    even if it prints `undefined`. This is arguably a bug in the Makefile,
    but even so, getconf shouldn't report that unsupported variables are
    valid.

diff --git a/getconf.1 b/getconf.1
index 8fcf960..71a4767 100644
--- a/getconf.1
+++ b/getconf.1
_AT_@ -32,7 +32,7 @@ and limits.h (Minimum and Maximum).
 .sp
 If
 .Ar var
-is not defined or has not been found,
+is not defined,
 .Nm
 writes "undefined" to stdout.
 .Sh OPTIONS
_AT_@ -48,7 +48,7 @@ was matched and its value written successfully.
 .It 1
 An error occured or
 .Ar var
-was neither defined nor found.
+was invalid.
 .El
 .Sh STANDARDS
 The
diff --git a/getconf.c b/getconf.c
index d927f2d..c7cfb06 100644
--- a/getconf.c
+++ b/getconf.c
_AT_@ -102,7 +102,5 @@ main(int argc, char *argv[])
                 usage();
         }
 
- puts("undefined");
-
- return 1;
+ eprintf("invalid variable: %s\n", argv[0]);
 }
Received on Mon Sep 04 2017 - 02:46:20 CEST

This archive was generated by hypermail 2.3.0 : Mon Sep 04 2017 - 02:48:32 CEST