From 7671136a573d7ed297618890896b0146c9ed96fc Mon Sep 17 00:00:00 2001 From: cheloha Date: Fri, 2 Dec 2022 22:29:59 +0000 Subject: [PATCH] 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@ --- usr.bin/midicat/midicat.c | 12 +++++++----- 1 file 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 * @@ -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); -- 2.20.1