summary refs log tree commit diff
path: root/.bin
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2016-09-15 23:25:49 -0400
committerJune McEnroe <june@causal.agency>2016-09-15 23:25:49 -0400
commit2feb7614ebc0b647b0d301ab9f30ffce783eafc2 (patch)
tree2cd547f6254236149eae6b0619ffd21010cc7d61 /.bin
parentUse sysexits.h in xx (diff)
downloadsrc-2feb7614ebc0b647b0d301ab9f30ffce783eafc2.tar.gz
src-2feb7614ebc0b647b0d301ab9f30ffce783eafc2.zip
Use err(3) in xx
Diffstat (limited to '')
-rwxr-xr-x.bin/xx.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/.bin/xx.c b/.bin/xx.c
index 9b8f5d0f..00b55391 100755
--- a/.bin/xx.c
+++ b/.bin/xx.c
@@ -3,6 +3,7 @@ exec clang -Weverything -Wno-vla $@ -o $(dirname $0)/xx $0
 #endif
 
 #include <ctype.h>
+#include <err.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -50,10 +51,7 @@ int main(int argc, char **argv) {
         path = argv[optind];
 
     FILE *file = path ? fopen(path, "r") : stdin;
-    if (!file) {
-        perror(path);
-        return EX_NOINPUT;
-    }
+    if (!file) err(EX_NOINPUT, "%s", path);
 
     uint8_t buf[cols];
     size_t offset = 0, len = 0, i;
@@ -92,9 +90,6 @@ int main(int argc, char **argv) {
         if (len < sizeof(buf)) break;
     }
 
-    if (ferror(file)) {
-        perror(path);
-        return EX_IOERR;
-    }
+    if (ferror(file)) err(EX_IOERR, "%s", path);
     return EX_OK;
 }