tty.c (9b50d9027575220cb6dd09b3e62f03f511e908b8) tty.c (1c8af8787354e20c2b38cab5801698133ff8b403)
1/*
2 * Copyright (c) 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 37 unchanged lines hidden (view full) ---

46main(argc, argv)
47 int argc;
48 char **argv;
49{
50 int ch, sflag;
51 char *t, *ttyname();
52
53 sflag = 0;
1/*
2 * Copyright (c) 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 37 unchanged lines hidden (view full) ---

46main(argc, argv)
47 int argc;
48 char **argv;
49{
50 int ch, sflag;
51 char *t, *ttyname();
52
53 sflag = 0;
54 while ((ch = getopt(argc, argv, "s")) != EOF)
54 while ((ch = getopt(argc, argv, "s")) != -1)
55 switch((char)ch) {
56 case 's':
57 sflag = 1;
58 break;
59 case '?':
60 default:
61 fputs("usage: tty [-s]\n", stderr);
62 exit(2);
63 }
64
65 t = ttyname(0);
66 if (!sflag)
67 puts(t ? t : "not a tty");
68 exit(t ? 0 : 1);
69}
55 switch((char)ch) {
56 case 's':
57 sflag = 1;
58 break;
59 case '?':
60 default:
61 fputs("usage: tty [-s]\n", stderr);
62 exit(2);
63 }
64
65 t = ttyname(0);
66 if (!sflag)
67 puts(t ? t : "not a tty");
68 exit(t ? 0 : 1);
69}