summaryrefslogtreecommitdiffstats
path: root/bin/sh/parser.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-09-03 14:16:06 +0000
committerpeter <peter@FreeBSD.org>1996-09-03 14:16:06 +0000
commit0475c084c22d974adb50e049f8526e7ba3325c20 (patch)
tree813be7fe988c4549d7c49e07f8aa26f6bed0c68a /bin/sh/parser.c
parent46c0540195d8219fc18878aaf2e8f89c0c6778dc (diff)
downloadFreeBSD-src-0475c084c22d974adb50e049f8526e7ba3325c20.zip
FreeBSD-src-0475c084c22d974adb50e049f8526e7ba3325c20.tar.gz
Fix for PR#1287. This makes sh behave sensibly in case statements in the
face of aliases. Note, bash doesn't do aliases while running scripts, but "real" ksh does.. Also: Reduce redundant .Nm macros in (unused) bltin/echo.1 nuke error2, it's hardly used. More -Wall cleanups dont do certain history operations if NO_HISTORY defined handle quad_t's from resource limits Submitted by: Steve Price <sprice@hiwaay.net> (minor tweaks by me)
Diffstat (limited to 'bin/sh/parser.c')
-rw-r--r--bin/sh/parser.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c
index 64a0cd0..d24508e 100644
--- a/bin/sh/parser.c
+++ b/bin/sh/parser.c
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: parser.c,v 1.11 1996/02/03 13:27:55 joerg Exp $
+ * $Id: parser.c,v 1.12 1996/09/01 10:21:31 peter Exp $
*/
#ifndef lint
@@ -95,6 +95,8 @@ struct heredoc *heredoc;
int quoteflag; /* set if (part of) last token was quoted */
int startlinno; /* line # where last token started */
+/* XXX When 'noaliases' is set to one, no alias expansion takes place. */
+static int noaliases = 0;
#define GDB_HACK 1 /* avoid local declarations which gdb can't handle */
#ifdef GDB_HACK
@@ -414,6 +416,7 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
if (lasttoken != TWORD || ! equal(wordtext, "in"))
synerror("expecting \"in\"");
cpp = &n1->ncase.cases;
+ noaliases = 1; /* turn off alias expansion */
checkkwd = 2, readtoken();
do {
*cpp = cp = (union node *)stalloc(sizeof (struct nclist));
@@ -431,18 +434,19 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
}
ap->narg.next = NULL;
if (lasttoken != TRP)
- synexpect(TRP);
+ noaliases = 0, synexpect(TRP);
cp->nclist.body = list(0);
checkkwd = 2;
if ((t = readtoken()) != TESAC) {
if (t != TENDCASE)
- synexpect(TENDCASE);
+ noaliases = 0, synexpect(TENDCASE);
else
checkkwd = 2, readtoken();
}
cpp = &cp->nclist.next;
} while(lasttoken != TESAC);
+ noaliases = 0; /* reset alias expansion */
*cpp = NULL;
checkkwd = 1;
break;
@@ -712,7 +716,8 @@ readtoken() {
goto out;
}
}
- if ((ap = lookupalias(wordtext, 1)) != NULL) {
+ if (noaliases == 0 &&
+ (ap = lookupalias(wordtext, 1)) != NULL) {
pushstring(ap->val, strlen(ap->val), ap);
checkkwd = savecheckkwd;
goto top;
OpenPOWER on IntegriCloud