1 /* 2 3 * Copyright (c) 1984, 1985, 1986 AT&T 4 * All Rights Reserved 5 6 * THIS IS UNPUBLISHED PROPRIETARY SOURCE 7 * CODE OF AT&T. 8 * The copyright notice above does not 9 * evidence any actual or intended 10 * publication of such source code. 11 12 */ 13 /* @(#)echo.c 1.1 */ 14 15 #ifdef KSHELL 16 #include "defs.h" 17 #include "brkincr.h" 18 #else 19 #include <stdio.h> 20 #endif /* KSHELL */ 21 22 /* 23 * echo the argument list on stream fd 24 * if raw is non-zero then \ is not a special character. 25 * returns 0 for \c otherwise 1. 26 */ 27 28 #ifdef KSHELL 29 extern void exitsh(); 30 #endif /* KSHELL */ 31 32 int echo_list(raw,com,fd) 33 int raw; 34 char *com[]; 35 register FILE *fd; 36 { 37 register int outc; 38 register char *cp; 39 while(cp= *com++) 40 { 41 for(; *cp; cp++) 42 { 43 outc = *cp; 44 if(*cp == '\\' && raw==0) 45 { 46 switch(*++cp) 47 { 48 case 'b': 49 outc = '\b'; 50 break; 51 case 'c': 52 return(0); 53 case 'f': 54 outc = '\f'; 55 break; 56 case 'n': 57 outc = '\n'; 58 break; 59 case 'r': 60 outc = '\r'; 61 break; 62 case 'v': 63 outc = '\v'; 64 break; 65 case 't': 66 outc = '\t'; 67 break; 68 case '\\': 69 outc = '\\'; 70 break; 71 case '0': 72 { 73 register char *cpmax; 74 outc = 0; 75 cpmax = cp + 4; 76 while(++cp<cpmax && *cp>='0' && 77 *cp<='7') 78 { 79 outc <<= 3; 80 outc |= (*cp-'0'); 81 } 82 cp--; 83 break; 84 } 85 default: 86 cp--; 87 } 88 } 89 putc (outc, fd); 90 } 91 if(*com) 92 putc(' ',fd); 93 #ifdef KSHELL 94 if(trapnote&SIGSET) 95 exitsh(SIGFAIL); 96 #endif /* KSHELL */ 97 } 98 return(1); 99 } 100 101