diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1996-11-02 01:00:35 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1996-11-02 01:00:35 +0000 |
commit | e1cebbbb830da1de265b39a3864c579690e29f57 (patch) | |
tree | bdd95cc749550e682dfee5fef3209609bf005e1a /bin/csh | |
parent | f721448d3193e19b89af480f0662d1851a75266f (diff) |
Update from NetBSD (christos)
Quote all imported environment variables.
Diffstat (limited to 'bin/csh')
-rw-r--r-- | bin/csh/csh.c | 10 | ||||
-rw-r--r-- | bin/csh/exec.c | 62 | ||||
-rw-r--r-- | bin/csh/extern.h | 5 | ||||
-rw-r--r-- | bin/csh/misc.c | 17 |
4 files changed, 62 insertions, 32 deletions
diff --git a/bin/csh/csh.c b/bin/csh/csh.c index 712bb1f12ae..536198ecdb6 100644 --- a/bin/csh/csh.c +++ b/bin/csh/csh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: csh.c,v 1.4 1996/10/27 23:45:32 millert Exp $ */ +/* $OpenBSD: csh.c,v 1.5 1996/11/02 01:00:30 millert Exp $ */ /* $NetBSD: csh.c,v 1.14 1995/04/29 23:21:28 mycroft Exp $ */ /*- @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93"; #else -static char rcsid[] = "$OpenBSD: csh.c,v 1.4 1996/10/27 23:45:32 millert Exp $"; +static char rcsid[] = "$OpenBSD: csh.c,v 1.5 1996/11/02 01:00:30 millert Exp $"; #endif #endif /* not lint */ @@ -251,15 +251,15 @@ main(argc, argv) */ if ((tcp = getenv("LOGNAME")) != NULL || (tcp = getenv("USER")) != NULL) - set(STRuser, SAVE(tcp)); + set(STRuser, quote(SAVE(tcp))); if ((tcp = getenv("TERM")) != NULL) - set(STRterm, SAVE(tcp)); + set(STRterm, quote(SAVE(tcp))); /* * Re-initialize path if set in environment */ if ((tcp = getenv("PATH")) == NULL) - set1(STRpath, defaultpath(), &shvhed); + setq(STRpath, defaultpath(), &shvhed); else importpath(SAVE(tcp)); diff --git a/bin/csh/exec.c b/bin/csh/exec.c index 8bb1d9c5481..30eefb20f7b 100644 --- a/bin/csh/exec.c +++ b/bin/csh/exec.c @@ -1,5 +1,5 @@ -/* $OpenBSD: exec.c,v 1.2 1996/06/23 14:19:20 deraadt Exp $ */ -/* $NetBSD: exec.c,v 1.8 1995/05/23 19:47:16 christos Exp $ */ +/* $OpenBSD: exec.c,v 1.3 1996/11/02 01:00:31 millert Exp $ */ +/* $NetBSD: exec.c,v 1.9 1996/09/30 20:03:54 christos Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)exec.c 8.3 (Berkeley) 5/23/95"; #else -static char rcsid[] = "$OpenBSD: exec.c,v 1.2 1996/06/23 14:19:20 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: exec.c,v 1.3 1996/11/02 01:00:31 millert Exp $"; #endif #endif /* not lint */ @@ -107,7 +107,7 @@ static Char *justabs[] = {STRNULL, 0}; static void pexerr __P((void)); static void texec __P((Char *, Char **)); static int hashname __P((Char *)); -static void tellmewhat __P((struct wordent *)); +static int tellmewhat __P((struct wordent *, Char *)); static int executable __P((Char *, Char *, bool)); static int iscommand __P((Char *)); @@ -647,28 +647,30 @@ dowhich(v, c) (void) fprintf(cshout, "%s: \t aliased to ", vis_str(*v)); blkpr(cshout, vp->vec); (void) fputc('\n', cshout); + set(STRstatus, Strsave(STR0)); } else { lex[1].word = *v; - tellmewhat(lex); + set(STRstatus, Strsave(tellmewhat(lex, NULL) ? STR0 : STR1)); } } } -static void -tellmewhat(lex) - struct wordent *lex; +static int +tellmewhat(lexp, str) + struct wordent *lexp; + Char *str; { register int i; register struct biltins *bptr; - register struct wordent *sp = lex->next; - bool aliased = 0; + register struct wordent *sp = lexp->next; + bool aliased = 0, found; Char *s0, *s1, *s2, *cmd; Char qc; if (adrof1(sp->word, &aliases)) { - alias(lex); - sp = lex->next; + alias(lexp); + sp = lexp->next; aliased = 1; } @@ -701,18 +703,22 @@ tellmewhat(lex) for (bptr = bfunc; bptr < &bfunc[nbfunc]; bptr++) { if (eq(sp->word, str2short(bptr->bname))) { + if (str == NULL) { if (aliased) - prlex(cshout, lex); + prlex(cshout, lexp); (void) fprintf(cshout, "%s: shell built-in command.\n", vis_str(sp->word)); + } + else + (void) Strcpy(str, sp->word); sp->word = s0; /* we save and then restore this */ - return; + return 1; } } sp->word = cmd = globone(sp->word, G_IGNORE); - if ((i = iscommand(strip(sp->word))) != 0) { + if ((i = iscommand(sp->word)) != 0) { register Char **pv; register struct varent *v; bool slash = any(short2str(sp->word), '/'); @@ -728,26 +734,36 @@ tellmewhat(lex) if (pv[0][0] == 0 || eq(pv[0], STRdot)) { if (!slash) { sp->word = Strspl(STRdotsl, sp->word); - prlex(cshout, lex); + prlex(cshout, lexp); xfree((ptr_t) sp->word); } else - prlex(cshout, lex); - sp->word = s0; /* we save and then restore this */ - xfree((ptr_t) cmd); - return; + prlex(cshout, lexp); } + else { s1 = Strspl(*pv, STRslash); sp->word = Strspl(s1, sp->word); xfree((ptr_t) s1); - prlex(cshout, lex); + if (str == NULL) + prlex(cshout, lexp); + else + (void) Strcpy(str, sp->word); xfree((ptr_t) sp->word); } + found = 1; + } else { + if (str == NULL) { if (aliased) - prlex(cshout, lex); - (void) fprintf(csherr, "%s: Command not found.\n", vis_str(sp->word)); + prlex(cshout, lexp); + (void) fprintf(csherr, + "%s: Command not found.\n", vis_str(sp->word)); + } + else + (void) Strcpy(str, sp->word); + found = 0; } sp->word = s0; /* we save and then restore this */ xfree((ptr_t) cmd); + return found; } diff --git a/bin/csh/extern.h b/bin/csh/extern.h index e062a1ddce6..26e697cfa70 100644 --- a/bin/csh/extern.h +++ b/bin/csh/extern.h @@ -1,5 +1,5 @@ -/* $OpenBSD: extern.h,v 1.2 1996/06/23 14:19:21 deraadt Exp $ */ -/* $NetBSD: extern.h,v 1.7 1995/03/21 14:51:58 mycroft Exp $ */ +/* $OpenBSD: extern.h,v 1.3 1996/11/02 01:00:32 millert Exp $ */ +/* $NetBSD: extern.h,v 1.8 1996/10/31 23:50:54 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -217,6 +217,7 @@ int prefix __P((Char *, Char *)); Char **saveblk __P((Char **)); void setzero __P((char *, int)); Char *strip __P((Char *)); +Char *quote __P((Char *)); char *strsave __P((char *)); char *strspl __P((char *, char *)); void udvar __P((Char *)); diff --git a/bin/csh/misc.c b/bin/csh/misc.c index 3ed9312ae57..818a9584f7a 100644 --- a/bin/csh/misc.c +++ b/bin/csh/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.3 1996/06/29 19:10:00 deraadt Exp $ */ +/* $OpenBSD: misc.c,v 1.4 1996/11/02 01:00:34 millert Exp $ */ /* $NetBSD: misc.c,v 1.6 1995/03/21 09:03:09 cgd Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: misc.c,v 1.3 1996/06/29 19:10:00 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: misc.c,v 1.4 1996/11/02 01:00:34 millert Exp $"; #endif #endif /* not lint */ @@ -402,6 +402,19 @@ strip(cp) return (cp); } +Char * +quote(cp) + Char *cp; +{ + register Char *dp = cp; + + if (!cp) + return (cp); + while (*dp != '\0') + *dp++ |= QUOTE; + return (cp); +} + void udvar(name) Char *name; |