Changeset 1205 in kBuild for trunk/src/kash
- Timestamp:
- Oct 7, 2007 2:30:32 PM (17 years ago)
- Location:
- trunk/src/kash
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/Makefile.kmk
r1204 r1205 48 48 expand.c \ 49 49 miscbltin.c \ 50 bltin/echo.c \ 50 51 \ 51 52 jobs.c \ … … 54 55 trap.c \ 55 56 var.c \ 56 bltin/echo.c \57 57 bltin/kill.c \ 58 58 bltin/test.c \ -
trunk/src/kash/bltin/echo.c
r626 r1205 52 52 */ 53 53 54 #define main echocmd55 56 54 #include "bltin.h" 57 55 58 56 int 59 main(int argc, char **argv)57 echocmd(shinstance *psh, int argc, char **argv) 60 58 { 61 59 char **ap; 62 char *p; 63 char c; 64 int count; 60 const char *p; 65 61 int nflag = 0; 66 62 int eflag = 0; … … 70 66 ap++; 71 67 72 if ((p = *ap) != NULL ) {73 if ( equal(p, "-n")) {68 if ((p = *ap) != NULL && *p == '-') { 69 if (p[1] == 'n' && !p[2]) { 74 70 nflag = 1; 75 71 ap++; 76 } else if ( equal(p, "-e")) {72 } else if (p[1] == 'e' && !p[2]) { 77 73 eflag = 1; 78 74 ap++; … … 81 77 82 78 while ((p = *ap++) != NULL) { 83 while ((c = *p++) != '\0') { 84 if (c == '\\' && eflag) { 85 switch (*p++) { 86 case 'a': c = '\a'; break; /* bell */ 87 case 'b': c = '\b'; break; 88 case 'c': return 0; /* exit */ 89 case 'e': c = 033; break; /* escape */ 90 case 'f': c = '\f'; break; 91 case 'n': c = '\n'; break; 92 case 'r': c = '\r'; break; 93 case 't': c = '\t'; break; 94 case 'v': c = '\v'; break; 95 case '\\': break; /* c = '\\' */ 96 case '0': 97 c = 0; 98 count = 3; 99 while (--count >= 0 && (unsigned)(*p - '0') < 8) 100 c = (c << 3) + (*p++ - '0'); 101 break; 102 default: 103 /* Output the '/' and char following */ 104 p--; 105 break; 79 if (!eflag) { 80 out1str(psh, p); 81 } else { 82 char c; 83 int count; 84 85 while ((c = *p++) != '\0') { 86 if (c == '\\') { 87 switch (*p++) { 88 case 'a': c = '\a'; break; /* bell */ 89 case 'b': c = '\b'; break; 90 case 'c': return 0; /* exit */ 91 case 'e': c = 033; break; /* escape */ 92 case 'f': c = '\f'; break; 93 case 'n': c = '\n'; break; 94 case 'r': c = '\r'; break; 95 case 't': c = '\t'; break; 96 case 'v': c = '\v'; break; 97 case '\\': break; /* c = '\\' */ 98 case '0': 99 c = 0; 100 count = 3; 101 while (--count >= 0 && (unsigned)(*p - '0') < 8) 102 c = (c << 3) + (*p++ - '0'); 103 break; 104 default: 105 /* Output the '/' and char following */ 106 p--; 107 break; 108 } 106 109 } 110 out1c(psh, c); 107 111 } 108 putchar(c);109 112 } 110 113 if (*ap) 111 putchar(' ');114 out1c(psh, ' '); 112 115 } 113 116 if (! nflag) 114 putchar('\n');117 out1c(psh, '\n'); 115 118 return 0; 116 119 }
Note:
See TracChangeset
for help on using the changeset viewer.