Download raw body.
tog: ensure stdin is a tty
On 22-09-03 04:55PM, Omar Polo wrote:
> On 2022/09/03 15:37:31 +0200, Stefan Sperling <stsp@stsp.name> wrote:
> > On Sat, Sep 03, 2022 at 11:24:47PM +1000, Mark Jamsek wrote:
> > > This was discussed a while back on IRC to handle such things like:
> > >
> > > $ tog < /dev/null
> > >
> > > ok?
> >
> > Should 'return 1' or exit(1) on error, not return GOT_ERR_IO.
>
> given the place where that check is, I'd go with an
>
> errx(1, "stardand input is not a tty");
>
> otherwise ok for me!
Thanks, stsp and op! Done.
diff refs/heads/main refs/heads/fix/tty
commit - 3d8e0c5ede1a5654397b63a9f483d875543527d5
commit + 7f04ea5dca27cc3e9751803d572f6792dde836d1
blob - 9d57af707725df8ed20c18c242b8359ad3a3270c
blob + 5b813c5e0de32f5883d2349934fb4b0280daa2ed
--- tog/tog.c
+++ tog/tog.c
@@ -8478,6 +8478,9 @@ main(int argc, char *argv[])
};
char *diff_algo_str = NULL;
+ if (!isatty(STDIN_FILENO))
+ errx(1, "stardand input is not a tty");
+
setlocale(LC_CTYPE, "");
while ((ch = getopt_long(argc, argv, "+hV", longopts, NULL)) != -1) {
--
Mark Jamsek <fnc.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68
tog: ensure stdin is a tty