summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Soule Cheloha <cheloha@cvs.openbsd.org>2022-12-02 22:30:00 +0000
committerScott Soule Cheloha <cheloha@cvs.openbsd.org>2022-12-02 22:30:00 +0000
commit25231158bc1e5b2377cfb3f00e827e77bae2211d (patch)
tree748e158eda9cbce2ba6959875f1fc658062ac546
parentdeae90b98f6e12a8199ca866dc381e872252c759 (diff)
midicat(1): set ifile/ofile to "stdin"/"stdout" if it is an en-dash ("-")
This makes error messages a little bit more intuitive. Instead of, e.g.: midicat: -: No space left on device you get: midicat: stdout: No space left on device Link: https://marc.info/?l=openbsd-tech&m=166982129428027&w=2 ok millert@ kn@ ratchov@
-rw-r--r--usr.bin/midicat/midicat.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/midicat/midicat.c b/usr.bin/midicat/midicat.c
index 21bb05ac78a..7c40dd748cd 100644
--- a/usr.bin/midicat/midicat.c
+++ b/usr.bin/midicat/midicat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: midicat.c,v 1.5 2022/12/02 22:21:35 cheloha Exp $ */
+/* $OpenBSD: midicat.c,v 1.6 2022/12/02 22:29:59 cheloha Exp $ */
/*
* Copyright (c) 2015 Alexandre Ratchov <alex@caoua.org>
*
@@ -92,9 +92,10 @@ main(int argc, char **argv)
/* open input or output file (if any) */
if (ifile) {
- if (strcmp(ifile, "-") == 0)
+ if (strcmp(ifile, "-") == 0) {
+ ifile = "stdin";
ifd = STDIN_FILENO;
- else {
+ } else {
ifd = open(ifile, O_RDONLY);
if (ifd == -1) {
perror(ifile);
@@ -102,9 +103,10 @@ main(int argc, char **argv)
}
}
} else if (ofile) {
- if (strcmp(ofile, "-") == 0)
+ if (strcmp(ofile, "-") == 0) {
+ ofile = "stdout";
ofd = STDOUT_FILENO;
- else {
+ } else {
ofd = open(ofile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (ofd == -1) {
perror(ofile);