1 /* 2 * Copyright (c) 1987 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 char copyright[] = 10 "@(#) Copyright (c) 1987 Regents of the University of California.\n\ 11 All rights reserved.\n"; 12 #endif /* not lint */ 13 14 #ifndef lint 15 static char sccsid[] = "@(#)printenv.c 5.4 (Berkeley) 06/01/90"; 16 #endif /* not lint */ 17 18 /* 19 * printenv 20 * 21 * Bill Joy, UCB 22 * February, 1979 23 */ 24 main(argc, argv) 25 int argc; 26 char **argv; 27 { 28 extern char **environ; 29 register char *cp, **ep; 30 register int len; 31 32 if (argc < 2) { 33 for (ep = environ; *ep; ep++) 34 puts(*ep); 35 exit(0); 36 } 37 len = strlen(*++argv); 38 for (ep = environ; *ep; ep++) 39 if (!strncmp(*ep, *argv, len)) { 40 cp = *ep + len; 41 if (!*cp || *cp == '=') { 42 puts(*cp ? cp + 1 : cp); 43 exit(0); 44 } 45 } 46 exit(1); 47 } 48