for debug; if HOME not set and root, write to /trace.
authorMarc Teitelbaum <marc@ucbvax.Berkeley.EDU>
Sat, 13 Apr 1991 09:28:17 +0000 (01:28 -0800)
committerMarc Teitelbaum <marc@ucbvax.Berkeley.EDU>
Sat, 13 Apr 1991 09:28:17 +0000 (01:28 -0800)
SCCS-vsn: bin/sh/show.c 5.2

usr/src/bin/sh/show.c

index 79a79a6..cd83791 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)show.c     5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)show.c     5.2 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <stdio.h>
 #endif /* not lint */
 
 #include <stdio.h>
@@ -213,6 +213,11 @@ indent(amount, pfx, fp)
 
 FILE *tracefile;
 
 
 FILE *tracefile;
 
+#if DEBUG == 2
+int debug = 1;
+#else
+int debug = 0;
+#endif
 
 
 trputc(c) {
 
 
 trputc(c) {
@@ -319,13 +324,19 @@ opentrace() {
        int flags;
 
 #ifdef DEBUG
        int flags;
 
 #ifdef DEBUG
-       if ((p = getenv("HOME")) == NULL)
-               p = "/tmp";
+       if (!debug)
+               return;
+       if ((p = getenv("HOME")) == NULL) {
+               if (getuid() == 0)
+                       p = "/";
+               else
+                       p = "/tmp";
+       }
        scopy(p, s);
        strcat(s, "/trace");
        if ((tracefile = fopen(s, "a")) == NULL) {
                fprintf(stderr, "Can't open %s\n", s);
        scopy(p, s);
        strcat(s, "/trace");
        if ((tracefile = fopen(s, "a")) == NULL) {
                fprintf(stderr, "Can't open %s\n", s);
-               exit(2);
+               return;
        }
 #ifdef O_APPEND
        if ((flags = fcntl(fileno(tracefile), F_GETFL, 0)) >= 0)
        }
 #ifdef O_APPEND
        if ((flags = fcntl(fileno(tracefile), F_GETFL, 0)) >= 0)