diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1998-06-25 19:02:48 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1998-06-25 19:02:48 +0000 |
commit | f7502f1aee86c9a3ebb4d6814e47a52727bc2d42 (patch) | |
tree | 0bd2bbab7d507d7dab286df7970c0101a3cb1807 /bin/ksh/var.c | |
parent | cc7df4d09ccd66ffca19799a357c049e1b5bf030 (diff) |
pdksh-5.2.13 + local changes
Diffstat (limited to 'bin/ksh/var.c')
-rw-r--r-- | bin/ksh/var.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/bin/ksh/var.c b/bin/ksh/var.c index 8350846a148..5f6ec98832a 100644 --- a/bin/ksh/var.c +++ b/bin/ksh/var.c @@ -1,4 +1,4 @@ -/* $OpenBSD: var.c,v 1.6 1997/09/01 18:30:16 deraadt Exp $ */ +/* $OpenBSD: var.c,v 1.7 1998/06/25 19:02:27 millert Exp $ */ #include "sh.h" #include "ksh_time.h" @@ -36,6 +36,7 @@ newblock() static char *const empty[] = {null}; l = (struct block *) alloc(sizeof(struct block), ATEMP); + l->flags = 0; ainit(&l->area); if (!e->loc) { l->argc = 0; @@ -68,6 +69,8 @@ popblock() setspec(vq); else unsetspec(vq); + if (l->flags & BF_DOGETOPTS) + user_opt = l->getopts_state; afreeall(&l->area); afree(l, ATEMP); } @@ -883,6 +886,11 @@ getspec(vp) vp->flag |= SPECIAL; break; #endif /* HISTORY */ + case V_OPTIND: + vp->flag &= ~SPECIAL; + setint(vp, (long) user_opt.uoptind); + vp->flag |= SPECIAL; + break; } } @@ -894,7 +902,9 @@ setspec(vp) switch (special(vp->name)) { case V_PATH: - path = str_val(vp); + if (path) + afree(path, APERM); + path = str_save(str_val(vp), APERM); flushcom(1); /* clear tracked aliases */ break; case V_IFS: @@ -902,7 +912,9 @@ setspec(vp) ifs0 = *s; break; case V_OPTIND: + vp->flag &= ~SPECIAL; getopts_reset((int) intval(vp)); + vp->flag |= SPECIAL; break; case V_POSIXLY_CORRECT: change_flag(FPOSIX, OF_SPECIAL, 1); @@ -981,7 +993,9 @@ unsetspec(vp) { switch (special(vp->name)) { case V_PATH: - path = def_path; + if (path) + afree(path, APERM); + path = str_save(def_path, APERM); flushcom(1); /* clear tracked aliases */ break; case V_IFS: |