diff options
Diffstat (limited to 'tc.func.c')
-rw-r--r-- | tc.func.c | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/tc.func.c b/tc.func.c index 9f2b1a29f4eb..1c1bf778bb6a 100644 --- a/tc.func.c +++ b/tc.func.c @@ -98,7 +98,7 @@ expand_lex(const struct wordent *sp0, int from, int to) const struct wordent *sp; Char *s; Char prev_c; - int i; + int i, dolsq = 0; prev_c = '\0'; @@ -113,11 +113,29 @@ expand_lex(const struct wordent *sp0, int from, int to) * character {(PWP) and backslash} seem to be dealt with * elsewhere. */ - if ((*s & QUOTE) - && (((*s & TRIM) == HIST && HIST != '\0') || - (((*s & TRIM) == '\'') && (prev_c != '\\')) || - (((*s & TRIM) == '\"') && (prev_c != '\\')))) { - Strbuf_append1(&buf, '\\'); + if (*s & QUOTE) { + if ((*s & TRIM) == HIST && HIST != '\0') + Strbuf_append1(&buf, '\\'); + else + switch (*s & TRIM) { + case '\'': + if (prev_c == '\\') break; + if (dolsq) { + dolsq = 0; + break; + } + if (prev_c == '$') { + dolsq++; + break; + } + Strbuf_append1(&buf, '\\'); + break; + case '\"': + if (prev_c == '\\') break; + if (dolsq) break; + Strbuf_append1(&buf, '\\'); + break; + } } #if INVALID_BYTE != 0 if ((*s & INVALID_BYTE) != INVALID_BYTE) /* *s < INVALID_BYTE */ @@ -336,7 +354,7 @@ dolist(Char **v, struct command *c) print_by_column(STRNULL, &v[i], k - i, FALSE); } haderr = 1; - xprintf("%S: %s.\n", tmp, strerror(err)); + xprintf("%" TCSH_S ": %s.\n", tmp, strerror(err)); haderr = 0; i = k + 1; ret = 1; @@ -351,7 +369,7 @@ dolist(Char **v, struct command *c) } if (k != 0 && v[1] != NULL) xputchar('\n'); - xprintf("%S:\n", tmp); + xprintf("%" TCSH_S ":\n", tmp); buf.len = 0; for (cp = tmp; *cp; cp++) Strbuf_append1(&buf, (*cp | QUOTE)); @@ -453,7 +471,7 @@ cmd_expand(Char *cmd, Char **str) if ((vp = adrof1(cmd, &aliases)) != NULL && vp->vec != NULL) { if (str == NULL) { - xprintf(CGETS(22, 1, "%S: \t aliased to "), cmd); + xprintf(CGETS(22, 1, "%" TCSH_S ": \t aliased to "), cmd); blkpr(vp->vec); xputchar('\n'); } @@ -485,7 +503,7 @@ dowhich(Char **v, struct command *c) rv &= cmd_expand(*v, NULL); if (!rv) - setcopy(STRstatus, STR1, VAR_READWRITE); + setstatus(1); } static int @@ -999,6 +1017,7 @@ aliasrun(int cnt, Char *s1, Char *s2) getexit(osetexit); if (seterr) { + cleanhist(); xfree(seterr); seterr = NULL; /* don't repeatedly print err msg. */ } @@ -1021,7 +1040,7 @@ aliasrun(int cnt, Char *s1, Char *s2) cleanup_push(&w, lex_cleanup); /* Save the old status */ - status = getn(varval(STRstatus)); + status = getstatus(); /* expand aliases like process() does. */ alias(&w); @@ -1075,8 +1094,9 @@ aliasrun(int cnt, Char *s1, Char *s2) } cleanup_until(&w); pendjob(); + cleanhist(); /* Restore status */ - setv(STRstatus, putn((tcsh_number_t)status), VAR_READWRITE); + setstrstatus(putn((tcsh_number_t)status)); } void @@ -1162,7 +1182,7 @@ rmstar(struct wordent *cp) cmd++; #ifdef RMDEBUG if (*tag) - xprintf(CGETS(22, 7, "parsing command line [%S]\n"), cmd); + xprintf(CGETS(22, 7, "parsing command line [%" TCSH_S "]\n"), cmd); #endif /* RMDEBUG */ if (!StrQcmp(cmd, STRrm)) { args = we->next; @@ -1223,7 +1243,7 @@ rmstar(struct wordent *cp) if (*tag) { xprintf(CGETS(22, 10, "command line now is:\n")); for (we = cp->next; we != cp; we = we->next) - xprintf("[%S] ", we->word); + xprintf("[%" TCSH_S "] ", we->word); } #endif /* RMDEBUG */ pintr_disabled = opintr_disabled; @@ -1298,7 +1318,7 @@ continue_jobs(struct wordent *cp) if (*tag) { xprintf(CGETS(22, 13, "command line now is:\n")); for (we = cp->next; we != cp; we = we->next) - xprintf("%S ", we->word); + xprintf("%" TCSH_S " ", we->word); } #endif /* CNDEBUG */ return; @@ -2105,7 +2125,7 @@ dotermname(Char **v, struct command *c) /* no luck - the user didn't provide one and none is * specified in the environment */ - setcopy(STRstatus, STR1, VAR_READWRITE); + setstatus(1); return; } @@ -2118,8 +2138,8 @@ dotermname(Char **v, struct command *c) */ if (tgetent(termcap_buffer, termtype) == 1) { xprintf("%s\n", termtype); - setcopy(STRstatus, STR0, VAR_READWRITE); + setstatus(0); } else - setcopy(STRstatus, STR1, VAR_READWRITE); + setstatus(1); } #endif /* WINNT_NATIVE */ |