---
toys/posix/getconf.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/toys/posix/getconf.c b/toys/posix/getconf.c
index d10365b..38c74d5 100644
--- a/toys/posix/getconf.c
+++ b/toys/posix/getconf.c
@@ -140,6 +140,12 @@ struct config others[] = {
{"LFS_CFLAGS", 0}, {"LFS_LDFLAGS", 0}, {"LFS_LIBS", 0}
};
+static void printconf(long v)
+{
+ if (v == -1) puts("undefined");
+ else printf("%ld\n", v);
+}
+
void getconf_main(void)
{
struct config *configs[] = {sysconfs, pathconfs, confstrs, limits, others},
@@ -178,8 +184,8 @@ void getconf_main(void)
if (toys.optc!=2) help_exit("%s needs a path", name);
} else if (toys.optc!=1) help_exit("%s does not take a path", name);
- if (!i) printf("%ld\n", sysconf(c->value));
- else if (i==1) printf("%ld\n", pathconf(toys.optargs[1], c->value));
+ if (!i) printconf(sysconf(c->value));
+ else if (i==1) printconf(pathconf(toys.optargs[1], c->value));
else if (i==2) {
confstr(c->value, toybuf, sizeof(toybuf));
puts(toybuf);
--
2.19.0.605.g01d371f741-goog
From 327fd22034281ea09a7fd047f3f8c51ca210a1ed Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Fri, 5 Oct 2018 15:29:59 -0700
Subject: [PATCH] getconf: say "undefined" for sysconf/pathconf -1.
---
toys/posix/getconf.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/toys/posix/getconf.c b/toys/posix/getconf.c
index d10365b..38c74d5 100644
--- a/toys/posix/getconf.c
+++ b/toys/posix/getconf.c
@@ -140,6 +140,12 @@ struct config others[] = {
{"LFS_CFLAGS", 0}, {"LFS_LDFLAGS", 0}, {"LFS_LIBS", 0}
};
+static void printconf(long v)
+{
+ if (v == -1) puts("undefined");
+ else printf("%ld\n", v);
+}
+
void getconf_main(void)
{
struct config *configs[] = {sysconfs, pathconfs, confstrs, limits, others},
@@ -178,8 +184,8 @@ void getconf_main(void)
if (toys.optc!=2) help_exit("%s needs a path", name);
} else if (toys.optc!=1) help_exit("%s does not take a path", name);
- if (!i) printf("%ld\n", sysconf(c->value));
- else if (i==1) printf("%ld\n", pathconf(toys.optargs[1], c->value));
+ if (!i) printconf(sysconf(c->value));
+ else if (i==1) printconf(pathconf(toys.optargs[1], c->value));
else if (i==2) {
confstr(c->value, toybuf, sizeof(toybuf));
puts(toybuf);
--
2.19.0.605.g01d371f741-goog
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net