coreutils

General Software Utilities
git clone http://git.omkov.net/coreutils
Log | Tree | Refs | README | LICENCE | Download

AuthorJamozed <[email protected]>
Date2020-07-06 10:31:57
Commit39afcc422fe1078e944a1f0ee62d5bd9de44424d
Parentc3d67f01ebfcd3620e8b39e83e7ffd5e8570a724

env: Use libokv error reporting

Diffstat

M src/env.c | 18 ++++++++++--------

1 files changed, 10 insertions, 8 deletions

diff --git a/src/env.c b/src/env.c
index b525f3f..889f3dd 100644
--- a/src/env.c
+++ b/src/env.c
@@ -1,4 +1,4 @@
-// env.c, version 1.0.0
+// env.c, version 1.0.1
 // OMKOV coreutils implementation of POSIX env
 // Copyright (C) 2020, Jakob Wakeling
 // All rights reserved.
@@ -33,22 +33,24 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
 */
 
-#include "error.h"
 #include "optget.h"
 
+#include <error.h>
+
 #include <unistd.h>
 
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
+
+#define VERSION "1.0.1"
 
 extern char **environ;
 
 static void help(void);
 static void version(void);
 
-int main(int argc, char *argv[]) {
+int main(int ac, char *av[]) { A0 = av[0];
 	lop_t lops[] = {
 		{ "help",    ARG_NUL, 256 },
 		{ "version", ARG_NUL, 257 },
@@ -56,14 +58,14 @@ int main(int argc, char *argv[]) {
 	};
 
 	opt_t opt = OPTGET_INIT; opt.str = "i"; opt.lops = lops; int o;
-	while((o = optget(&opt, argv, 0)) != -1) switch (o) {
+	while((o = optget(&opt, av, 0)) != -1) switch (o) {
 	case 'i': { environ = NULL; break; }
 	case 256: { help(); return 0; }
 	case 257: { version(); return 0; }
 	default: { return 1; }
 	}
 
-	register char **p = &argv[opt.ind];
+	register char **p = &av[opt.ind];
 	for (; *p && strchr(*p, '=') != NULL; ++p) { putenv(*p); }
 
 	if (!*p) { if (environ) for (char **v = environ; *v; ++v) {
@@ -72,7 +74,7 @@ int main(int argc, char *argv[]) {
 
 	execvp(*p, &*p);
 
-	warn("%s: %s: %s", argv[0], *p, serrno);
+	warn("%s: %s", *p, serr());
 	return errno = ENOENT ? 127 : 126;
 }
 
@@ -87,7 +89,7 @@ static void help(void) {
 }
 
 static void version() {
-	puts("OMKOV coreutils env, version 1.0.0");
+	puts("OMKOV coreutils env, version " VERSION);
 	puts("Copyright (C) 2020, Jakob Wakeling");
 	puts("All rights reserved.");
 	puts("OMKOV Permissive Licence (https://www.omkov.net/OLPE)");