diff -rud --new-file ash-elks-1/Makefile ash/Makefile
--- ash-elks-1/Makefile	Wed Feb 11 00:26:58 1998
+++ ash/Makefile	Wed Feb 18 23:55:06 1998
@@ -1,4 +1,7 @@
 # Makefile for ash.
+#
+# 19980209 Claudio Matsuoka <claudio@pos.inf.ufpr.br>
+# Modified for ELKS and bcc
 
 SRCS=	builtins.c cd.c dirent.c error.c eval.c exec.c expand.c input.c \
 	jobs.c mail.c main.c memalloc.c miscbltin.c mystring.c nodes.c \
@@ -9,14 +12,14 @@
 	jobs.o mail.o main.o memalloc.o miscbltin.o mystring.o nodes.o \
 	options.o parser.o redir.o show.o signames.o syntax.o trap.o \
 	output.o var.o init.o \
-	bltin/echo.o #bltin/expr.o bltin/regexp.o bltin/operators.o
+	bltin/echo.o bltin/expr.o bltin/regexp.o bltin/operators.o
 
 #
 # Set READLINE in shell.h and add -ledit to LIBS if you want to use the
 # editline package by Simmule Turner and Rich Salz.  (The big, bloated
 # and GPL contaminated FSF readline should work too.)
 #
-CC = bcc
+CC= bcc
 CPPFLAGS= -DSHELL -I. -D_MINIX -D_POSIX_SOURCE -Dsig_t=int
 CFLAGS=	-0 -O -I/usr/bcc/include  $(CPPFLAGS)
 LIBS=	#-ledit
@@ -30,7 +33,6 @@
 
 sh:	$(OBJS)
 	$(CC) $(CFLAGS) -o sh $(OBJS) $(LIBS)
-	#install -S 64k sh
 
 install:	/usr/bin/ash
 
diff -rud --new-file ash-elks-1/README.elks ash/README.elks
--- ash-elks-1/README.elks	Wed Feb 18 11:46:00 1998
+++ ash/README.elks	Thu Feb 19 00:09:02 1998
@@ -1,13 +1,23 @@
 
 This is an experimental port of the Almquist shell (ash) for ELKS and bcc.
 It was ported from the MINIX version found in ftp.funet.fi:/pub/minix/src.
-My comments are marked with `CSM:'.
 
-Note note note! This version does NOT work with real ELKS (but does with
-elksemu)
+Copyright (C) 1989 Kenneth Almquist.
+Copyright (C) 1991 The Regents of the University of California.
 
-claudio@pos.inf.ufpr.br (Claudio Matsuoka)
-Mon Feb  9 17:40:59 EST 1998
+Ash is distributed under the terms of the BSD License and the Ash General
+Public License. See the file bltin/LICENSE for more information.
+
+
+
+Change log:
+
+--------------------------------------------------------------
+19980209 Claudio Matsuoka <claudio@pos.inf.ufpr.br>
+
+(*) Initial port (quite trivial).
+    Adjusted makefiles for bcc, defined sig_t as int, kicked out some
+    stuff not supported by bcc (look for FIXME in comments).
 
 --------------------------------------------------------------
 19980216 Vincent Zweije <zweije@xs4all.nl>
@@ -47,5 +57,15 @@
 (*) Implement pipes.
     Ash handled their lack reasonably gracefully.
     Very important for some powerful but easy to use IPC.
+
+--------------------------------------------------------------
+19980218 Claudio Matsuoka <claudio@pos.inf.ufpr.br>
+
+(*) Workaround for bcc miscompilation in bltin/expr.c.
+    bcc complained about "invalid indirect to indirect" and "invalid label"
+    errors.
+
+(*) Workaround for bcc miscompilation in bltin/regexp.c.
+    bcc complained about "invalid indirect to indirect" errors.
 
 --------------------------------------------------------------
diff -rud --new-file ash-elks-1/bltin/expr.c ash/bltin/expr.c
--- ash-elks-1/bltin/expr.c	Mon Feb  9 10:11:38 1998
+++ ash/bltin/expr.c	Wed Feb 18 23:53:11 1998
@@ -172,8 +172,21 @@
 	    while (opsp < &opstack[STACKSIZE] && opsp->pri >= pri) {
 		  binary = opsp->op;
 		  for (;;) {
+			/*
+			 * 19980218 Claudio Matsuoka <claudio@pos.inf.ufpr.br>
+			 * Oh my, this is a nasty one! Once again, bcc
+			 * complains about invalid indirect to indirect
+			 * (mov byte ptr -9[bp],#_op_argflag[bx]).
+			 */
+#if 0
 			valsp--;
 			c = op_argflag[opsp->op];
+#else
+			char *kludge;
+			kludge = op_argflag;
+			kludge += opsp->op;
+			c = *kludge;
+#endif
 			if (c == OP_INT) {
 			      if (valsp->type == STRING)
 				    valsp->u.num = atol(valsp->u.string);
@@ -266,6 +279,17 @@
  * to stat, to avoid repeated stat calls on the same file.
  */
 
+/*
+ * 19980218 Claudio Matsuoka <claudio@pos.inf.ufpr.br>
+ * So, here's one more workaround for a bcc problem. This time bcc
+ * complains about an illegal label when using `goto filetype'.
+ */
+
+#define GOTO_FILETYPE_WORKAROUND { \
+	sp->u.num = ((fs->stat.st_mode & S_IFMT) == i && fs->rcode >= 0); \
+	sp->type = BOOLEAN; \
+	break; }
+
 void
 expr_operator(op, sp, fs)
       int op;
@@ -299,17 +323,17 @@
 	    goto filetype;
       case ISDIR:
 	    i = S_IFDIR;
-	    goto filetype;
+	    GOTO_FILETYPE_WORKAROUND;
       case ISCHAR:
 	    i = S_IFCHR;
-	    goto filetype;
+	    GOTO_FILETYPE_WORKAROUND;
       case ISBLOCK:
 	    i = S_IFBLK;
-	    goto filetype;
+	    GOTO_FILETYPE_WORKAROUND;
       case ISFIFO:
 #ifdef S_IFIFO
 	    i = S_IFIFO;
-	    goto filetype;
+	    GOTO_FILETYPE_WORKAROUND;
 #else
 	    goto false;
 #endif
Binary files ash-elks-1/bltin/expr.o and ash/bltin/expr.o differ
diff -rud --new-file ash-elks-1/bltin/regexp.c ash/bltin/regexp.c
--- ash-elks-1/bltin/regexp.c	Tue Oct  1 09:00:00 1996
+++ ash/bltin/regexp.c	Thu Feb 19 00:01:28 1998
@@ -205,6 +205,8 @@
 	char *r;
 	int len;
 	char c;
+	short *kludge;
+	char **kludge2;
 
 	p = pattern;
 	q = string;
@@ -257,8 +259,25 @@
 			p++;
 			break;
 		case RE_MATCHED:
+			/*
+			 * 19980218 Claudio Matsuoka <claudio@pos.inf.ufpr.br>
+			 * Workaround for bcc compilation problem
+			 */
+			
+#if 0
 			r = match_begin[*p];
 			len = match_length[*p++];
+#else
+			kludge2 = match_begin;
+			kludge2 += *p;
+			r = *kludge2;
+
+			kludge = match_length;
+			kludge += *p;
+			len = *kludge;
+			p++;
+#endif
+
 			while (--len >= 0) {
 				if (*q++ != *r++)
 					goto bad;
@@ -289,8 +308,19 @@
 	if (! counting)
 		return 0;
 	len = 1;
-	if (*curpat == RE_MATCHED)
+	if (*curpat == RE_MATCHED) {
+		/*
+		 * 19980218 Claudio Matsuoka <claudio@pos.inf.ufpr.br>
+		 * Yet another workaround for a bcc problem.
+		 */
+#if 0
 		len = match_length[curpat[1]];
+#else
+		kludge = match_length;
+		kludge += curpat[1];
+		len = *kludge;
+#endif
+	}
 	while (--count >= low) {
 		if (match(p, start_count + count * len))
 			return 1;
Binary files ash-elks-1/bltin/regexp.o and ash/bltin/regexp.o differ
diff -rud --new-file ash-elks-1/expand.c ash/expand.c
--- ash-elks-1/expand.c	Sun Feb  8 23:36:22 1998
+++ ash/expand.c	Wed Feb 18 12:37:33 1998
@@ -490,7 +490,11 @@
 			STPUTC(*p++, expdest);
 		break;
 #if 0
-	/* CSM: problems with bcc */
+	/*
+	 * 19980209 Claudio Matsuoka <claudio@pos.inf.ufpr.br>
+	 * FIXME: Commented out due to problems with bcc (illegal
+	 * indirect to indirect: mov byte ptr -1[si],#_optchar[bx]).
+	 */
 	case '-':
 		for (i = 0 ; optchar[i] ; i++) {
 			if (optval[i])
diff -rud --new-file ash-elks-1/parser.c ash/parser.c
--- ash-elks-1/parser.c	Mon Feb  9 17:38:06 1998
+++ ash/parser.c	Wed Feb 18 12:08:53 1998
@@ -678,7 +678,10 @@
  *  have parseword (readtoken1?) handle both words and redirection.]
  */
 
-/* CSM: `return lasttoken = token' does not work with bcc */
+/*
+ * 19980209 Claudio Matsuoka <claudio@pos.inf.ufpr.br>
+ * bcc fails with `return lasttoken = token', returning an invalid value.
+ */
 #define RETURN(token)	{ lasttoken = token; return token; }
 
 STATIC int
diff -rud --new-file ash-elks-1/trap.c ash/trap.c
--- ash-elks-1/trap.c	Wed Feb 18 11:46:00 1998
+++ ash/trap.c	Thu Feb 19 00:07:25 1998
@@ -150,7 +150,11 @@
 	extern void onsig();
 
 #if 0
-	/* CSM: problems with bcc */
+	/*
+	 * 1998021 Claudio Matsuoka <claudio@pos.inf.ufpr.br>
+	 * FIXME: Commented out due to problems with bcc (Illegal
+	 * indirect to indirect: mov word ptr -$A[bp],#_trap[bx]).
+	 */
 	if ((t = trap[signo]) == NULL)
 		action = S_DFL;
 	else if (*t != '\0')
