diff options
Diffstat (limited to 'sh.func.c')
-rw-r--r-- | sh.func.c | 72 |
1 files changed, 13 insertions, 59 deletions
diff --git a/sh.func.c b/sh.func.c index ede623f2ff10..0cb2e391c7b3 100644 --- a/sh.func.c +++ b/sh.func.c @@ -227,9 +227,9 @@ dofiletest(Char **v, struct command *c) cleanup_push(globbed, blk_cleanup); while (*(fileptr = v++) != NULL) { - res = filetest(ftest, &fileptr, 0); + res = filetest(ftest, &fileptr, TEXP_NOGLOB); cleanup_push(res, xfree); - xprintf("%S", res); + xprintf("%" TCSH_S, res); cleanup_until(res); if (*v) xprintf(" "); @@ -493,7 +493,7 @@ doexit(Char **v, struct command *c) */ v++; if (*v) { - setv(STRstatus, putn(expr(&v)), VAR_READWRITE); + setstrstatus(putn(expr(&v))); if (*v) stderror(ERR_NAME | ERR_EXPRESSION); } @@ -1199,7 +1199,8 @@ doglob(Char **v, struct command *c) static void xecho(int sep, Char **v) { - Char *cp, **globbed = NULL; + Char **globbed = NULL; + const Char *cp; int nonl = 0; int echo_style = ECHO_STYLE; struct varent *vp; @@ -1235,7 +1236,7 @@ xecho(int sep, Char **v) nonl++, v++; while ((cp = *v++) != 0) { - Char c; + eChar c; if (setintr) { int old_pintr_disabled; @@ -1243,63 +1244,16 @@ xecho(int sep, Char **v) pintr_push_enable(&old_pintr_disabled); cleanup_until(&old_pintr_disabled); } - while ((c = *cp++) != 0) { + for (; (c = *cp) != 0; cp++) { if ((echo_style & SYSV_ECHO) != 0 && c == '\\') { - switch (c = *cp++) { - case 'a': - c = '\a'; - break; - case 'b': - c = '\b'; - break; - case 'c': - nonl = 1; - goto done; - case 'e': -#if 0 /* Windows does not understand \e */ - c = '\e'; -#else - c = CTL_ESC('\033'); -#endif - break; - case 'f': - c = '\f'; - break; - case 'n': - c = '\n'; - break; - case 'r': - c = '\r'; - break; - case 't': - c = '\t'; - break; - case 'v': - c = '\v'; - break; - case '\\': + if ((c = parseescape(&cp, FALSE)) == CHAR_ERR) c = '\\'; - break; - case '0': - c = 0; - if (*cp >= '0' && *cp < '8') - c = c * 8 + *cp++ - '0'; - if (*cp >= '0' && *cp < '8') - c = c * 8 + *cp++ - '0'; - if (*cp >= '0' && *cp < '8') - c = c * 8 + *cp++ - '0'; - break; - case '\0': - c = '\\'; - cp--; - break; - default: - xputchar('\\' | QUOTE); + else if (c == CHAR_EOF) { + nonl++; break; } } xputwchar(c | QUOTE); - } if (*v) xputchar(sep | QUOTE); @@ -1356,7 +1310,7 @@ doprintenv(Char **v, struct command *c) pintr_push_enable(&old_pintr_disabled); cleanup_until(&old_pintr_disabled); } - xprintf("%S\n", *ep); + xprintf("%" TCSH_S "\n", *ep); } cleanup_until(&xlate_cr); } @@ -1366,11 +1320,11 @@ doprintenv(Char **v, struct command *c) old_output_raw = output_raw; output_raw = 1; cleanup_push(&old_output_raw, output_raw_restore); - xprintf("%S\n", e); + xprintf("%" TCSH_S "\n", e); cleanup_until(&old_output_raw); } else - setcopy(STRstatus, STR1, VAR_READWRITE); + setstatus(1); } /* from "Karl Berry." <karl%mote.umb.edu@relay.cs.net> -- for NeXT things |