Date: Sat, 25 May 1996 10:30:01 -0700 (PDT) From: "Lars Fredriksen" <fredriks@mcs.com> To: freebsd-bugs Subject: Re: bin/1248: shell having problem parsing arguments Message-ID: <199605251730.KAA05023@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/1248; it has been noted by GNATS. From: "Lars Fredriksen" <fredriks@mcs.com> To: joerg_wunsch@uriah.heep.sax.de Cc: FreeBSD-gnats-submit@FreeBSD.org Subject: Re: bin/1248: shell having problem parsing arguments Date: Sat, 25 May 1996 12:20:34 -0500 (CDT) J Wunsch writes: > > Aw! Can you please re-submit this as a context (or uni) diff? > (The -c or -u flags to [cvs] diff.) It's nearly impossible to > integrate plain diffs. > > You can simply followup to this thread, GNATS will append it then to > the PR. > > -- > cheers, J"org > Hi J"org, Sorry about that, here they are: Lars Index: parser.c =================================================================== RCS file: /home/ncvs/src/bin/sh/parser.c,v retrieving revision 1.11 diff -c -r1.11 parser.c *** parser.c 1996/02/03 13:27:55 1.11 --- parser.c 1996/04/16 04:16:37 *************** *** 1108,1115 **** } else { if (! is_special(c)) badsub: synerror("Bad substitution"); ! USTPUTC(c, out); ! c = pgetc(); } STPUTC('=', out); flags = 0; --- 1108,1123 ---- } else { if (! is_special(c)) badsub: synerror("Bad substitution"); ! ! if (is_digit(c)) { ! do { ! STPUTC(c, out); ! c = pgetc(); ! } while( is_digit(c)); ! } else { ! USTPUTC(c, out); ! c = pgetc(); ! } } STPUTC('=', out); flags = 0; Index: expand.c =================================================================== RCS file: /home/ncvs/src/bin/sh/expand.c,v retrieving revision 1.4 diff -c -r1.4 expand.c *** expand.c 1995/05/30 00:07:13 1.4 --- expand.c 1996/05/24 17:13:03 *************** *** 90,97 **** STATIC void argstr(char *, int); STATIC void expbackq(union node *, int, int); STATIC char *evalvar(char *, int); ! STATIC int varisset(int); ! STATIC void varvalue(int, int, int); STATIC void recordregion(int, int, int); STATIC void ifsbreakup(char *, struct arglist *); STATIC void expandmeta(struct strlist *, int); --- 90,97 ---- STATIC void argstr(char *, int); STATIC void expbackq(union node *, int, int); STATIC char *evalvar(char *, int); ! STATIC int varisset(char *); ! STATIC void varvalue(char *, int, int); STATIC void recordregion(int, int, int); STATIC void ifsbreakup(char *, struct arglist *); STATIC void expandmeta(struct strlist *, int); *************** *** 453,459 **** p = strchr(p, '=') + 1; again: /* jump here after setting a variable with ${var=text} */ if (special) { ! set = varisset(*var); val = NULL; } else { val = lookupvar(var); --- 453,459 ---- p = strchr(p, '=') + 1; again: /* jump here after setting a variable with ${var=text} */ if (special) { ! set = varisset(var); val = NULL; } else { val = lookupvar(var); *************** *** 467,473 **** if (set && subtype != VSPLUS) { /* insert the value of the variable */ if (special) { ! varvalue(*var, varflags & VSQUOTE, flag & EXP_FULL); } else { char const *syntax = (varflags & VSQUOTE)? DQSYNTAX : BASESYNTAX; --- 467,473 ---- if (set && subtype != VSPLUS) { /* insert the value of the variable */ if (special) { ! varvalue(var, varflags & VSQUOTE, flag & EXP_FULL); } else { char const *syntax = (varflags & VSQUOTE)? DQSYNTAX : BASESYNTAX; *************** *** 539,560 **** STATIC int varisset(name) ! char name; { char **ap; ! if (name == '!') { if (backgndpid == -1) return 0; ! } else if (name == '@' || name == '*') { if (*shellparam.p == NULL) return 0; ! } else if ((unsigned)(name -= '1') <= '9' - '1') { ! ap = shellparam.p; ! do { ! if (*ap++ == NULL) ! return 0; ! } while (--name >= 0); } return 1; } --- 539,571 ---- STATIC int varisset(name) ! char *name; { + char *t; + int numvar; char **ap; ! if (*name == '!') { if (backgndpid == -1) return 0; ! } else if (*name == '@' || *name == '*') { if (*shellparam.p == NULL) return 0; ! } else { ! t = name; ! while (is_digit(*t++)) { ! ; ! } ! ! if ( *--t == '=' ) { ! *t = '\0'; ! numvar = atoi(name); ! ap = shellparam.p; ! do { ! if (*ap++ == NULL) ! return 0; ! } while (--numvar > 0); ! } } return 1; } *************** *** 567,577 **** STATIC void varvalue(name, quoted, allow_split) ! char name; { int num; char temp[32]; char *p; int i; extern int exitstatus; char sep; --- 578,590 ---- STATIC void varvalue(name, quoted, allow_split) ! char *name; { int num; + int numvar; char temp[32]; char *p; + char *t; int i; extern int exitstatus; char sep; *************** *** 593,599 **** } while (0) ! switch (name) { case '$': num = rootpid; goto numvar; --- 606,612 ---- } while (0) ! switch (*name) { case '$': num = rootpid; goto numvar; *************** *** 640,647 **** STRTODEST(p); break; default: ! if ((unsigned)(name -= '1') <= '9' - '1') { ! p = shellparam.p[name]; STRTODEST(p); } break; --- 653,666 ---- STRTODEST(p); break; default: ! ! t = name; ! while (is_digit(*t++)) { ! } ! ! if ( *t == '\0' ) { ! numvar = atoi(name); ! p = shellparam.p[numvar-1]; STRTODEST(p); } break; -- ------------------------------------------------------------------- Lars Fredriksen fredriks@mcs.com (home) lars@fredriks.pr.mcs.net (home-home)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605251730.KAA05023>