diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/Makefile.in bash-2.03/Makefile.in
*** bash203/Makefile.in	Thu Feb 18 12:07:38 1999
--- bash-2.03/Makefile.in	Sun Jan 16 17:32:00 2000
***************
*** 1,7 ****
  # Makefile for bash-2.03, version 2.103
  #
  # Make sure the first target in the makefile is the right one
! all: .made
  
  # Include some boilerplate Gnu makefile definitions.
  prefix = @prefix@
--- 1,7 ----
  # Makefile for bash-2.03, version 2.103
  #
  # Make sure the first target in the makefile is the right one
! all: _made
  
  # Include some boilerplate Gnu makefile definitions.
  prefix = @prefix@
***************
*** 46,51 ****
--- 46,56 ----
  
  TESTSCRIPT = @TESTSCRIPT@
  
+ YACC_OUTPUT_ROOT = @YACC_OUTPUT_ROOT@
+ YACC_OUTPUT_ROOT_H = $(YACC_OUTPUT_ROOT).h
+ YACC_OUTPUT_ROOT_C = $(YACC_OUTPUT_ROOT).c
+ YACC_OUTPUT_ROOT_O = $(YACC_OUTPUT_ROOT).o
+ 
  #If you have purify, and want to use it, uncomment this definition or
  # run the make as `make PURIFY=purify'
  # or run configure with the --with-purify argument.
***************
*** 58,64 ****
  	$(CC) $(CCFLAGS) -c $<
  
  # The name of this program and some version information.
! Program = bash
  Version = @BASHVERS@
  PatchLevel = @BASHPATCH@
  RELSTATUS = release
--- 63,69 ----
  	$(CC) $(CCFLAGS) -c $<
  
  # The name of this program and some version information.
! Program = bash.exe
  Version = @BASHVERS@
  PatchLevel = @BASHPATCH@
  RELSTATUS = release
***************
*** 280,293 ****
  # The shell itself
  #
  
  # The main source code for the Bourne Again SHell.
! CSOURCES = shell.c eval.c parse.y general.c make_cmd.c print_cmd.c y.tab.c \
  	   dispose_cmd.c execute_cmd.c variables.c $(GLOBC) version.c \
  	   expr.c copy_cmd.c flags.c subst.c hashcmd.c hashlib.c mailcheck.c \
  	   test.c trap.c alias.c jobs.c nojobs.c $(ALLOC_FILES) braces.c \
  	   input.c bashhist.c array.c sig.c pathexp.c \
  	   unwind_prot.c siglist.c bashline.c bracecomp.c error.c \
! 	   list.c stringlib.c locale.c findcmd.c redir.c xmalloc.c
  
  HSOURCES = shell.h flags.h trap.h hashcmd.h hashlib.h jobs.h builtins.h \
  	   general.h variables.h config.h $(ALLOC_HEADERS) alias.h maxpath.h \
--- 285,304 ----
  # The shell itself
  #
  
+ # files for dos
+ DOS_SOURCES = dosutil.c tminit.c
+ DOS_HEADERS = dosutil.h
+ DOS_OBJECTS = $(DOS_SOURCES:.c=.o)
+ 
  # The main source code for the Bourne Again SHell.
! CSOURCES = shell.c eval.c parse.y general.c make_cmd.c print_cmd.c $(YACC_OUTPUT_ROOT_C) \
  	   dispose_cmd.c execute_cmd.c variables.c $(GLOBC) version.c \
  	   expr.c copy_cmd.c flags.c subst.c hashcmd.c hashlib.c mailcheck.c \
  	   test.c trap.c alias.c jobs.c nojobs.c $(ALLOC_FILES) braces.c \
  	   input.c bashhist.c array.c sig.c pathexp.c \
  	   unwind_prot.c siglist.c bashline.c bracecomp.c error.c \
! 	   list.c stringlib.c locale.c findcmd.c redir.c xmalloc.c \
!            $(DOS_SOURCES)
  
  HSOURCES = shell.h flags.h trap.h hashcmd.h hashlib.h jobs.h builtins.h \
  	   general.h variables.h config.h $(ALLOC_HEADERS) alias.h maxpath.h \
***************
*** 296,302 ****
  	   subst.h externs.h siglist.h bashhist.h bashline.h bashtypes.h \
  	   array.h sig.h mailcheck.h bashtty.h bashintl.h bashjmp.h ${GRAM_H} \
  	   posixwait.h execute_cmd.h memalloc.h parser.h pathexp.h pathnames.h \
! 	   posixjmp.h stdc.h unionwait.h $(BASHPOSIX_SUPPORT)
  
  SOURCES	 = $(CSOURCES) $(HSOURCES) $(BUILTIN_DEFS)
  
--- 307,313 ----
  	   subst.h externs.h siglist.h bashhist.h bashline.h bashtypes.h \
  	   array.h sig.h mailcheck.h bashtty.h bashintl.h bashjmp.h ${GRAM_H} \
  	   posixwait.h execute_cmd.h memalloc.h parser.h pathexp.h pathnames.h \
!            posixjmp.h stdc.h unionwait.h $(BASHPOSIX_SUPPORT) $(DOS_HEADERS)
  
  SOURCES	 = $(CSOURCES) $(HSOURCES) $(BUILTIN_DEFS)
  
***************
*** 307,318 ****
  JOBS_O = @JOBS_O@
  
  # Matching object files.
! OBJECTS	 = shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o $(GLOBO) \
  	   dispose_cmd.o execute_cmd.o variables.o copy_cmd.o error.o \
  	   expr.o flags.o $(JOBS_O) subst.o hashcmd.o hashlib.o mailcheck.o \
  	   trap.o input.o unwind_prot.o pathexp.o sig.o test.o version.o \
  	   alias.o array.o braces.o bracecomp.o bashhist.o bashline.o \
! 	   siglist.o list.o stringlib.o locale.o findcmd.o redir.o xmalloc.o
  
  # Where the source code of the shell builtins resides.
  BUILTIN_SRCDIR=$(srcdir)/builtins
--- 318,330 ----
  JOBS_O = @JOBS_O@
  
  # Matching object files.
! OBJECTS	 = shell.o eval.o $(YACC_OUTPUT_ROOT_O) general.o make_cmd.o print_cmd.o $(GLOBO) \
  	   dispose_cmd.o execute_cmd.o variables.o copy_cmd.o error.o \
  	   expr.o flags.o $(JOBS_O) subst.o hashcmd.o hashlib.o mailcheck.o \
  	   trap.o input.o unwind_prot.o pathexp.o sig.o test.o version.o \
  	   alias.o array.o braces.o bracecomp.o bashhist.o bashline.o \
! 	   siglist.o list.o stringlib.o locale.o findcmd.o redir.o xmalloc.o \
!            $(DOS_OBJECTS)
  
  # Where the source code of the shell builtins resides.
  BUILTIN_SRCDIR=$(srcdir)/builtins
***************
*** 384,399 ****
  # Keep GNU Make from exporting the entire environment for small machines.
  .NOEXPORT:
  
! .made: $(Program) bashbug
! 	@echo "$(Program) last made for a $(Machine) running $(OS)" >.made
  
! $(Program):  .build $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP)
  	$(RM) $@
  	$(PURIFY) $(CC) $(BUILTINS_LDFLAGS) $(LIBRARY_LDFLAGS) $(LDFLAGS) -o $(Program) $(OBJECTS) $(LIBS)
  	ls -l $(Program)
  	size $(Program)
  
! .build:	$(SOURCES) config.h Makefile version.h
  	@echo
  	@echo "	  ***********************************************************"
  	@echo "	  *                                                         *"
--- 396,411 ----
  # Keep GNU Make from exporting the entire environment for small machines.
  .NOEXPORT:
  
! _made: $(Program) bashbug
! 	@echo "$(Program) last made for a $(Machine) running $(OS)" >_made
  
! $(Program):  _build $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP)
  	$(RM) $@
  	$(PURIFY) $(CC) $(BUILTINS_LDFLAGS) $(LIBRARY_LDFLAGS) $(LDFLAGS) -o $(Program) $(OBJECTS) $(LIBS)
  	ls -l $(Program)
  	size $(Program)
  
! _build:	$(SOURCES) config.h Makefile version.h
  	@echo
  	@echo "	  ***********************************************************"
  	@echo "	  *                                                         *"
***************
*** 410,416 ****
  	     $(SUPPORT_SRC)bashbug.sh > $@
  	@chmod a+rx bashbug
  
! strip:	$(Program) .made
  	strip $(Program)
  	ls -l $(Program)
  	size $(Program)
--- 422,428 ----
  	     $(SUPPORT_SRC)bashbug.sh > $@
  	@chmod a+rx bashbug
  
! strip:	$(Program) _made
  	strip $(Program)
  	ls -l $(Program)
  	size $(Program)
***************
*** 421,442 ****
  
  # old rules
  GRAM_H = parser-built
! y.tab.o: y.tab.c ${GRAM_H} command.h stdc.h input.h
! ${GRAM_H}:	y.tab.h
! 	@-if test -f y.tab.h ; then \
! 		cmp -s $@ y.tab.h 2>/dev/null || cp -p y.tab.h $@; \
  	fi
! y.tab.c y.tab.h: parse.y
! #	-if test -f y.tab.h; then mv -f y.tab.h old-y.tab.h; fi
  	$(YACC) -d $(srcdir)/parse.y
! #	-if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h; else cp -p y.tab.h ${GRAM_H}; fi
  
  # experimental new rules - work with GNU make but not BSD (or OSF) make
! #y.tab.o: y.tab.c y.tab.h
! #y.tab.c y.tab.h: parse.y command.h stdc.h input.h
! #	-if test -f y.tab.h; then mv -f y.tab.h old-y.tab.h; fi
  #	$(YACC) -d $(srcdir)/parse.y
! #	-if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h; fi
  
  $(READLINE_LIBRARY): config.h $(READLINE_SOURCE)
  	@echo making $@ in ${RL_LIBDIR}
--- 433,454 ----
  
  # old rules
  GRAM_H = parser-built
! $(YACC_OUTPUT_ROOT_O): $(YACC_OUTPUT_ROOT_C) ${GRAM_H} command.h stdc.h input.h
! ${GRAM_H}:	$(YACC_OUTPUT_ROOT_H)
! 	@-if test -f $YACC_OUTPUT_ROOT_H ; then \
! 		cmp -s $@ $YACC_OUTPUT_ROOT_H 2>/dev/null || cp -p $YACC_OUTPUT_ROOT_H $@; \
  	fi
! $(YACC_OUTPUT_ROOT_C) $(YACC_OUTPUT_ROOT_H): parse.y
! #	-if test -f $YACC_OUTPUT_ROOT_H; then mv -f $YACC_OUTPUT_ROOT_H old-$YACC_OUTPUT_ROOT_H.h; fi
  	$(YACC) -d $(srcdir)/parse.y
! #	-if cmp -s old-$YACC_OUTPUT_ROOT_H $YACC_OUTPUT_ROOT_H; then mv old-$YACC_OUTPUT_ROOT_H $YACC_OUTPUT_ROOT_H; else cp -p $YACC_OUTPUT_ROOT_H ${GRAM_H}; fi
  
  # experimental new rules - work with GNU make but not BSD (or OSF) make
! #$(YACC_OUTPUT_ROOT_O): $(YACC_OUTPUT_ROOT_C) $(YACC_OUTPUT_ROOT_H)
! #$(YACC_OUTPUT_ROOT_C) $(YACC_OUTPUT_ROOT_H): parse.y command.h stdc.h input.h
! #	-if test -f $YACC_OUTPUT_ROOT_H; then mv -f $YACC_OUTPUT_ROOT_H old-$YACC_OUTPUT_ROOT_H; fi
  #	$(YACC) -d $(srcdir)/parse.y
! #	-if cmp -s old-$YACC_OUTPUT_ROOT_H $YACC_OUTPUT_ROOT_H; then mv old-$YACC_OUTPUT_ROOT_H $YACC_OUTPUT_ROOT_H; fi
  
  $(READLINE_LIBRARY): config.h $(READLINE_SOURCE)
  	@echo making $@ in ${RL_LIBDIR}
***************
*** 507,520 ****
  
  config.h:	stamp-h 
  
! stamp-h:	config.status $(srcdir)/config.h.in $(srcdir)/config-top.h $(srcdir)/config-bot.h
! 	CONFIG_FILES= CONFIG_HEADERS=config.h $(SHELL) ./config.status
  
  config.status:	$(srcdir)/configure
  	$(SHELL) ./config.status --recheck
  
  # comment out for distribution
! $(srcdir)/configure:	$(srcdir)/configure.in $(srcdir)/aclocal.m4 $(srcdir)/config.h.in
  	cd $(srcdir) && autoconf
  
  # for chet
--- 519,532 ----
  
  config.h:	stamp-h 
  
! stamp-h:	config.status $(srcdir)/config.h-in $(srcdir)/config-top.h $(srcdir)/config-bot.h
! 	CONFIG_FILES= CONFIG_HEADERS=config.h:config.h-in $(SHELL) ./config.status
  
  config.status:	$(srcdir)/configure
  	$(SHELL) ./config.status --recheck
  
  # comment out for distribution
! $(srcdir)/configure:	$(srcdir)/configure.in $(srcdir)/aclocal.m4 $(srcdir)/config.h-in
  	cd $(srcdir) && autoconf
  
  # for chet
***************
*** 522,528 ****
  	sh $(srcdir)/configure
  
  #newversion:	mkversion
! #	$(RM) .build
  #	./mkversion -dir $(srcdir) -dist
  #	mv -f newversion.h version.h
  #	$(MAKE) -f $(srcdir)/Makefile $(MFLAGS) srcdir=$(srcdir)
--- 534,540 ----
  	sh $(srcdir)/configure
  
  #newversion:	mkversion
! #	$(RM) _build
  #	./mkversion -dir $(srcdir) -dist
  #	mv -f newversion.h version.h
  #	$(MAKE) -f $(srcdir)/Makefile $(MFLAGS) srcdir=$(srcdir)
***************
*** 548,554 ****
  	@${SHELL} $(SUPPORT_SRC)mkdirs $(man1dir) $(man3dir)
  	@${SHELL} $(SUPPORT_SRC)mkdirs $(infodir)
  
! install:	.made installdirs
  	$(INSTALL_PROGRAM) $(INSTALLMODE) $(Program) $(bindir)/$(Program)
  	$(INSTALL_PROGRAM) $(INSTALLMODE) bashbug $(bindir)/bashbug
  	-( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \
--- 560,566 ----
  	@${SHELL} $(SUPPORT_SRC)mkdirs $(man1dir) $(man3dir)
  	@${SHELL} $(SUPPORT_SRC)mkdirs $(infodir)
  
! install:	_made installdirs
  	$(INSTALL_PROGRAM) $(INSTALLMODE) $(Program) $(bindir)/$(Program)
  	$(INSTALL_PROGRAM) $(INSTALLMODE) bashbug $(bindir)/bashbug
  	-( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \
***************
*** 560,566 ****
  	$(MAKE) $(MFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
  		prefix=${prefix} exec_prefix=${exec_prefix} install
  
! uninstall:	.made
  	$(RM) $(bindir)/$(Program) $(bindir)/bashbug
  	-( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \
  		man1dir=$(man1dir) man1ext=$(man1ext) \
--- 572,578 ----
  	$(MAKE) $(MFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
  		prefix=${prefix} exec_prefix=${exec_prefix} install
  
! uninstall:	_made
  	$(RM) $(bindir)/$(Program) $(bindir)/bashbug
  	-( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \
  		man1dir=$(man1dir) man1ext=$(man1ext) \
***************
*** 570,576 ****
  .PHONY: basic-clean clean realclean maintainer-clean distclean mostlyclean
  basic-clean:
  	$(RM) $(OBJECTS) $(Program) bashbug
! 	$(RM) .build .made version.h
  
  clean:	basic-clean
  	( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
--- 582,588 ----
  .PHONY: basic-clean clean realclean maintainer-clean distclean mostlyclean
  basic-clean:
  	$(RM) $(OBJECTS) $(Program) bashbug
! 	$(RM) _build _made version.h
  
  clean:	basic-clean
  	( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
***************
*** 611,617 ****
  maintainer-clean:	basic-clean
  	@echo This command is intended for maintainers to use.
  	@echo It deletes files that may require special tools to rebuild.
! 	$(RM) y.tab.c y.tab.h parser-built.h tags TAGS
  	( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
  	( cd builtins && $(MAKE) $(MFLAGS) $@ )
  	-(cd $(RL_LIBDIR) && $(MAKE) $(MFLAGS) $@)
--- 623,629 ----
  maintainer-clean:	basic-clean
  	@echo This command is intended for maintainers to use.
  	@echo It deletes files that may require special tools to rebuild.
! 	$(RM) $(YACC_OUTPUT_ROOT_C) $(YACC_OUTPUT_ROOT_H) parser-built.h tags TAGS
  	( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ )
  	( cd builtins && $(MAKE) $(MFLAGS) $@ )
  	-(cd $(RL_LIBDIR) && $(MAKE) $(MFLAGS) $@)
***************
*** 660,666 ****
  # to be changed
  shell.o: config-top.h
  input.o: config-top.h
! y.tab.o: config-top.h
  jobs.o: config-top.h
  nojobs.o: config-top.h
  execute_cmd.o: config-top.h
--- 672,678 ----
  # to be changed
  shell.o: config-top.h
  input.o: config-top.h
! $(YACC_OUTPUT_ROOT_O): config-top.h
  jobs.o: config-top.h
  nojobs.o: config-top.h
  execute_cmd.o: config-top.h
***************
*** 750,762 ****
  make_cmd.o: command.h stdc.h general.h error.h flags.h make_cmd.h
  make_cmd.o: variables.h array.h hashlib.h subst.h input.h externs.h
  make_cmd.o: jobs.h quit.h siglist.h
! y.tab.o: config.h bashtypes.h bashansi.h ansi_stdlib.h memalloc.h
! y.tab.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
! y.tab.o: general.h bashtypes.h variables.h array.h hashlib.h
! y.tab.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
! y.tab.o: make_cmd.h subst.h sig.h pathnames.h externs.h
! y.tab.o: trap.h flags.h parser.h input.h mailcheck.h $(DEFSRC)/common.h
! y.tab.o: $(DEFDIR)/builtext.h bashline.h bashhist.h jobs.h siglist.h alias.h
  pathexp.o: config.h bashtypes.h bashansi.h ansi_stdlib.h
  pathexp.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
  pathexp.o: general.h bashtypes.h variables.h array.h hashlib.h
--- 762,774 ----
  make_cmd.o: command.h stdc.h general.h error.h flags.h make_cmd.h
  make_cmd.o: variables.h array.h hashlib.h subst.h input.h externs.h
  make_cmd.o: jobs.h quit.h siglist.h
! $(YACC_OUTPUT_ROOT_O): config.h bashtypes.h bashansi.h ansi_stdlib.h memalloc.h
! $(YACC_OUTPUT_ROOT_O): shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
! $(YACC_OUTPUT_ROOT_O): general.h bashtypes.h variables.h array.h hashlib.h
! $(YACC_OUTPUT_ROOT_O): quit.h maxpath.h unwind_prot.h dispose_cmd.h
! $(YACC_OUTPUT_ROOT_O): make_cmd.h subst.h sig.h pathnames.h externs.h
! $(YACC_OUTPUT_ROOT_O): trap.h flags.h parser.h input.h mailcheck.h $(DEFSRC)/common.h
! $(YACC_OUTPUT_ROOT_O): $(DEFDIR)/builtext.h bashline.h bashhist.h jobs.h siglist.h alias.h
  pathexp.o: config.h bashtypes.h bashansi.h ansi_stdlib.h
  pathexp.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
  pathexp.o: general.h bashtypes.h variables.h array.h hashlib.h
***************
*** 824,830 ****
  variables.o: make_cmd.h subst.h sig.h pathnames.h externs.h
  variables.o: flags.h execute_cmd.h mailcheck.h input.h $(DEFSRC)/common.h
  variables.o: findcmd.h bashhist.h
! version.o: version.h .build
  xmalloc.o: config.h bashtypes.h ansi_stdlib.h error.h
  
  # job control
--- 836,842 ----
  variables.o: make_cmd.h subst.h sig.h pathnames.h externs.h
  variables.o: flags.h execute_cmd.h mailcheck.h input.h $(DEFSRC)/common.h
  variables.o: findcmd.h bashhist.h
! version.o: version.h _build
  xmalloc.o: config.h bashtypes.h ansi_stdlib.h error.h
  
  # job control
***************
*** 889,896 ****
  bashline.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h
  bracecomp.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
  bracecomp.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
! y.tab.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
! y.tab.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
  subst.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
  subst.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
  
--- 901,908 ----
  bashline.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h
  bracecomp.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
  bracecomp.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
! $(YACC_OUTPUT_ROOT_O): $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
! $(YACC_OUTPUT_ROOT_O): $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
  subst.o: $(RL_LIBSRC)/keymaps.h $(RL_LIBSRC)/chardefs.h
  subst.o: $(RL_LIBSRC)/readline.h $(RL_LIBSRC)/rlstdc.h
  
***************
*** 898,904 ****
  subst.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
  bashline.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
  bashhist.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
! y.tab.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
  
  execute_cmd.o: $(TILDE_LIBSRC)/tilde.h
  general.o: $(TILDE_LIBSRC)/tilde.h
--- 910,916 ----
  subst.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
  bashline.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
  bashhist.o: $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
! $(YACC_OUTPUT_ROOT_O): $(HIST_LIBSRC)/history.h $(HIST_LIBSRC)/rlstdc.h
  
  execute_cmd.o: $(TILDE_LIBSRC)/tilde.h
  general.o: $(TILDE_LIBSRC)/tilde.h
***************
*** 1139,1141 ****
--- 1151,1157 ----
  builtins/ulimit.o: $(DEFSRC)/ulimit.def
  builtins/umask.o: $(DEFSRC)/umask.def
  builtins/wait.o: $(DEFSRC)/wait.def
+ 
+ # dos dependencies
+ dosutil.o: dosutil.h
+ 
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/aclocal.m4 bash-2.03/aclocal.m4
*** bash203/aclocal.m4	Wed Dec 30 11:06:40 1998
--- bash-2.03/aclocal.m4	Thu Jul 22 13:27:46 1999
***************
*** 1299,1301 ****
--- 1299,1425 ----
  if test $bash_cv_off_t_64 = yes; then
          AC_DEFINE(HAVE_OFF_T_64)
  fi])
+ 
+ dnl Macros that test for features involving DOS specific features
+ dnl or features that aren't implemented in DOS
+ 
+ dnl
+ dnl Check whether the target OS uses DOS-style pathnames.
+ dnl This includes the use of drive letters and backslashes.
+ dnl Defines HAVE_PATHNAME_STYLE_DOS under DOS, Windows, and OS/2.
+ dnl
+ AC_DEFUN(ACX_CHECK_PATHNAME_STYLE_DOS,
+ [AC_MSG_CHECKING(for Windows and DOS and OS/2 style pathnames)
+ AC_CACHE_VAL(acx_cv_pathname_style_dos,
+ [AC_REQUIRE([AC_CANONICAL_HOST])
+ acx_cv_pathname_style_dos="no"
+ case ${host_os} in
+   *djgpp | *mingw32 | *emx*) acx_cv_pathname_style_dos="yes" ;;
+ esac
+ ])
+ AC_MSG_RESULT($acx_cv_pathname_style_dos)
+ if test $acx_cv_pathname_style_dos = "yes"; then
+   AC_DEFINE(HAVE_PATHNAME_STYLE_DOS)
+ fi
+ ])
+ 
+ dnl
+ dnl Check if the target is running on DOS.
+ dnl DOS doesn't allow a dot as the first character,
+ dnl more than one dot, more than eight characters before
+ dnl a dot, and just three letters after the dot.
+ dnl A DOS VM running under Windows 9X does not have these
+ dnl restrictions. A DOS program can be running in either
+ dnl environment, so code accordingly.
+ dnl Defines HAVE_DOS_FILESYS_LIMITATIONS only under DOS.
+ dnl
+ AC_DEFUN(ACX_CHECK_DOS_FILESYS_LIMITATIONS,
+ [AC_MSG_CHECKING(for DOS filesystem limitations)
+ AC_CACHE_VAL(acx_cv_dos_limitations,
+ [AC_REQUIRE([AC_CANONICAL_HOST])
+ acx_cv_dos_limitations="yes"
+ case ${host_os} in
+   *dos | *djgpp) acx_cv_dos_limitations="yes"
+ esac
+ ])
+ AC_MSG_RESULT($acx_cv_dos_limitations)
+ if test $acx_cv_dos_limitations = "yes"; then
+   AC_DEFINE(HAVE_DOS_FILESYS_LIMITATIONS)
+ fi
+ ])
+ 
+ dnl
+ dnl Check to see what the default name is used for your
+ dnl port of yacc or bison. DOS and VMS output y_tab.c
+ dnl due to filename limitations. Unix and most others
+ dnl output y.tab.c. Set YACC_OUTPUT_ROOT and HAVE_Y_TAB_H accordingly.
+ dnl
+ AC_DEFUN(ACX_PROG_YACC_OUTPUT_ROOT,
+ [AC_MSG_CHECKING(for the yacc output root)
+ AC_CACHE_VAL(acx_cv_prog_yacc_output_root,
+ [AC_REQUIRE([AC_PROG_YACC])
+ ac_dir="conf$$"
+ mkdir $ac_dir
+ cat > ./$ac_dir/conftest.y << EOF
+ %token NUM
+ 
+ %%
+ 
+ input:
+ ;
+ %%
+ EOF
+ ( cd $ac_dir
+ $YACC conftest.y
+ )
+ acx_cv_prog_yacc_root="y.tab"
+ if test -f ./$ac_dir/y_tab.c; then
+   acx_cv_prog_yacc_root="y_tab"
+   rm -f ./$ac_dir/y_tab.c
+ else
+   rm -f ./$ac_dir/y.tab.c
+ fi
+ rm -f ./$ac_dir/conftest.y
+ rmdir ./$ac_dir
+ ])
+ AC_MSG_RESULT($acx_cv_prog_yacc_root)
+ YACC_OUTPUT_ROOT=$acx_cv_prog_yacc_root
+ AC_SUBST(YACC_OUTPUT_ROOT)
+ AC_DEFINE(HAVE_Y_TAB_H)
+ ])
+ 
+ dnl
+ dnl Check to for a working fork. Define HAVE_NO_FORK if fork() doesn't work.
+ dnl
+ AC_DEFUN(ACX_FUNC_FORK,
+ [AC_MSG_CHECKING(for a working fork)
+ AC_CACHE_VAL(acx_cv_func_fork_works,
+ [AC_REQUIRE([AC_TYPE_PID_T])
+ AC_TRY_RUN([#include <sys/types.h>
+ #include <sys/wait.h>
+ #ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif
+ 
+ int main()
+ {
+   int status;
+   pid_t child = fork();
+ 
+   if (child < 0) /* Error */
+     return (1);
+   else if (child == 0) /* Child */
+     return (0);
+ 
+   /* Parent */
+   status = (wait(&status) != child);
+   return  (status >= 0) ? 0 : 1;   
+ }
+ ], acx_cv_func_fork_works=yes, acx_cv_func_fork_works=no, acx_cv_func_fork_works=no)
+ ])
+ AC_MSG_RESULT($acx_cv_func_fork_works)
+ if test $acx_cv_func_fork_works = no; then
+   AC_DEFINE(HAVE_NO_FORK)
+ fi
+ ])
+ 
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/alias.c bash-2.03/alias.c
*** bash203/alias.c	Tue Mar 17 13:30:34 1998
--- bash-2.03/alias.c	Fri Feb 19 17:41:44 1999
***************
*** 37,42 ****
--- 37,47 ----
  #include "externs.h"
  #include "alias.h"
  
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ 
  static int qsort_alias_compare ();
  
  /* Non-zero means expand all words on the line.  Otherwise, expand
***************
*** 291,297 ****
--- 296,307 ----
       character. */
    for (i = start + 1 ; string[i] ; i++)
      {
+ #if defined (USE_MULTIBYTE)
+       if (string[i] == '\\'
+ 	  && (i-(start+1) == 0 || _mbsbtype (string+start+1, i-(start+1)) != _MBC_TRAIL))
+ #else
        if (string[i] == '\\')
+ #endif
  	{
  	  i++;		/* skip backslash-quoted quote characters, too */
  	  continue;
***************
*** 335,340 ****
--- 345,358 ----
  	  continue;
  	}
  
+ #if defined (USE_MULTIBYTE)
+       if (_ismbblead (string[i]))
+ 	{
+ 	  pass_next = 1;
+ 	  continue;
+ 	}
+ #endif
+ 
        if (string[i] == '\\')
  	{
  	  peekc = string[i+1];
***************
*** 400,406 ****
--- 418,429 ----
    /* From here to next separator character is a token. */
    for (i = start; string[i] && token_char (string[i]); i++)
      {
+ #if defined (USE_MULTIBYTE)
+       if (string[i] == '\\' && (i-start == 0
+ 				|| _mbsbtype (string+start, i-start) != _MBC_TRAIL))
+ #else
        if (string[i] == '\\')
+ #endif
  	{
  	  i++;	/* skip backslash-escaped character */
  	  continue;
***************
*** 499,505 ****
--- 522,532 ----
        /* If there is a backslash-escaped character quoted in TOKEN,
  	 then we don't do alias expansion.  This should check for all
  	 other quoting characters, too. */
+ #if defined (USE_MULTIBYTE)
+       if (_mbschr (token, '\\'))
+ #else
        if (strchr (token, '\\'))
+ #endif
  	expand_this_token = 0;
  
        /* If we should be expanding here, if we are expanding all words, or if
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/authors bash-2.03/authors
*** bash203/authors	Fri Jan  3 17:02:52 1997
--- bash-2.03/authors	Tue Jan 11 16:48:44 2000
***************
*** 16,22 ****
  aclocal.m4	Chet Ramey
  config.h.top	Chet Ramey
  config.h.bot	Chet Ramey
! config.h.in	Chet Ramey
  array.c		Chet Ramey
  print_cmd.c	Brian Fox, Chet Ramey
  general.c	Brian Fox, Chet Ramey
--- 16,22 ----
  aclocal.m4	Chet Ramey
  config.h.top	Chet Ramey
  config.h.bot	Chet Ramey
! config.h-in	Chet Ramey
  array.c		Chet Ramey
  print_cmd.c	Brian Fox, Chet Ramey
  general.c	Brian Fox, Chet Ramey
***************
*** 87,94 ****
  bashtypes.h	Chet Ramey
  bashtty.h	Chet Ramey
  pathnames.h	Chet Ramey
! y.tab.c		Brian Fox, Chet Ramey
! y.tab.h		Brian Fox, Chet Ramey
  parser-built	Brian Fox, Chet Ramey
  posixstat.h	Brian Fox, Chet Ramey
  stdc.h		Chet Ramey
--- 87,94 ----
  bashtypes.h	Chet Ramey
  bashtty.h	Chet Ramey
  pathnames.h	Chet Ramey
! y_tab.c		Brian Fox, Chet Ramey
! y_tab.h		Brian Fox, Chet Ramey
  parser-built	Brian Fox, Chet Ramey
  posixstat.h	Brian Fox, Chet Ramey
  stdc.h		Chet Ramey
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/bashhist.c bash-2.03/bashhist.c
*** bash203/bashhist.c	Wed Oct  7 12:09:26 1998
--- bash-2.03/bashhist.c	Fri Feb 19 17:41:44 1999
***************
*** 50,55 ****
--- 50,63 ----
  #  include "bashline.h"
  #endif
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ 
  #if !defined (errno)
  extern int errno;
  #endif
***************
*** 242,247 ****
--- 250,258 ----
  
    /* Read the history in HISTFILE into the history list. */
    hf = get_string_value ("HISTFILE");
+ #if defined (__MSDOS__)
+   hf = dosutil_expand_path (savestring (hf));
+ #endif
  
    if (hf && *hf && stat (hf, &buf) == 0)
      {
***************
*** 249,254 ****
--- 260,269 ----
        using_history ();
        history_lines_in_file = where_history ();
      }
+ #if defined (__MSDOS__)
+   if (hf)
+     free (hf);
+ #endif
  }
  
  #ifdef INCLUDE_UNUSED
***************
*** 260,265 ****
--- 275,283 ----
    struct stat buf;
  
    hf = get_string_value ("HISTFILE");
+ #if defined (__MSDOS__)
+   hf = dosutil_expand_path (savestring (hf));
+ #endif
    if (hf && *hf && stat (hf, &buf) == 0)
      {
        /* Append only the lines that occurred this session to
***************
*** 273,278 ****
--- 291,300 ----
  
        sv_histsize ("HISTFILESIZE");
      }
+ #if defined (__MSDOS__)
+   if (hf)
+     free (hf);
+ #endif
  }
  #endif
  
***************
*** 536,543 ****
--- 558,573 ----
  	     newline, since that is what happens when the line is parsed. */
  	  curlen = strlen (current->line);
  
+ #if defined (USE_MULTIBYTE)
+ 	  if (dstack.delimiter_depth == 0 && curlen > 2 &&
+ 	      current->line[curlen - 1] == '\\' &&
+ 	      _mbsbtype (current->line, curlen-1) != _MBC_TRAIL &&
+ 	      (_mbsbtype (current->line, curlen-2) == _MBC_TRAIL ||
+ 	       current->line[curlen - 2] != '\\'))
+ #else
  	  if (dstack.delimiter_depth == 0 && current->line[curlen - 1] == '\\' &&
  	      current->line[curlen - 2] != '\\')
+ #endif
  	    {
  	      current->line[curlen - 1] = '\0';
  	      curlen--;
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/bashline.c bash-2.03/bashline.c
*** bash203/bashline.c	Wed Sep 16 15:12:58 1998
--- bash-2.03/bashline.c	Sat Aug 14 18:49:08 1999
***************
*** 49,54 ****
--- 49,64 ----
  #  include "alias.h"
  #endif
  
+ #if defined (__MSDOS__)
+ #include "general.h"
+ #include "dosutil.h"
+ #endif
+ 
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ 
  #if defined (BRACE_COMPLETION)
  extern void bash_brace_completion ();
  #endif /* BRACE_COMPLETION */
***************
*** 309,315 ****
--- 319,329 ----
    enable_hostname_completion (perform_hostname_completion);
  
    /* characters that need to be quoted when appearing in filenames. */
+ #ifndef HAVE_PATHNAME_STYLE_DOS
    rl_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!:";
+ #else
+   rl_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!";
+ #endif
    rl_filename_quoting_function = bash_quote_filename;
    rl_filename_dequoting_function = bash_dequote_filename;
    rl_char_is_quoted_p = char_is_quoted;
***************
*** 687,693 ****
--- 701,712 ----
        if (current_prompt_string == ps1_prompt)
  	in_command_position++;
      }
+ #if defined (USE_MULTIBYTE)
+   else if (member (rl_line_buffer[ti], command_separator_chars)
+ 	   && (ti == 0 || _mbsbtype (rl_line_buffer, ti) != _MBC_TRAIL))
+ #else
    else if (member (rl_line_buffer[ti], command_separator_chars))
+ #endif
      {
        register int this_char, prev_char;
  
***************
*** 806,811 ****
--- 825,863 ----
  	 aliases, reserved words, functions or builtins.  We must check
  	 whether or not it is unique, and, if so, whether that filename
  	 is executable. */
+ #ifdef HAVE_PATHNAME_STYLE_DOS
+      if (hint_text && hint_text[1] == ':' && hint_text[2] != '/')
+        {
+          char buffer[FILENAME_MAX];
+          char ch_save;
+ 
+ #ifdef __DJGPP__
+          _fixpath (hint_text, buffer);
+          hint = strdup (buffer);
+ #else
+          getcwd (buffer, FILENAME_MAX);
+ 
+          ch_save = hint_text[2];
+          hint_text[2] = '\0';
+          chdir (hint_text);
+          hint_text[2] = ch_save;
+ 
+          hint = getcwd (NULL, FILENAME_MAX);
+          chdir (buffer);
+ #endif
+ 
+          hint_len = strlen (hint);
+          if (filename_hint)
+            free (filename_hint);
+ 
+          filename_hint = savestring (hint);
+ 
+          mapping_over = 4;
+          istate = 0;
+          goto inner;
+        }
+      else
+ #endif
        if (absolute_program (hint_text))
  	{
  	  /* Perform tilde expansion on what's passed, so we don't end up
***************
*** 928,935 ****
--- 980,992 ----
  
        /* Get the next directory from the path.  If there is none, then we
  	 are all done. */
+ #if defined (__MSDOS__)
+       if (!path || !path[path_index] ||
+ 	  (current_path = extract_unit (path, &path_index, dosutil_path_separator)) == 0)
+ #else
        if (!path || !path[path_index] ||
  	  (current_path = extract_colon_unit (path, &path_index)) == 0)
+ #endif
  	return ((char *)NULL);
  
        if (*current_path == 0)
***************
*** 1010,1016 ****
--- 1067,1087 ----
  
        /* If we have found a match, and it is an executable file or a
  	 directory name, return it. */
+ #if defined (__MSDOS__)
+       if (match)
+ 	{
+ 	  char *fixp;
+ 
+ 	  fixp = dosutil_expand_path (savestring (val));
+ 	  /* allocte space for dot and three extenction characters */
+ 	  fixp = xrealloc (fixp, strlen (fixp) + 5);
+ 	  match = (executable_file (fixp) || is_directory (val));
+ 	  free (fixp);
+ 	}
+       if (match)
+ #else
        if (match && (executable_file (val) || is_directory (val)))
+ #endif
  	{
  	  free (val);
  	  val = "";		/* So it won't be NULL. */
***************
*** 1588,1593 ****
--- 1659,1668 ----
    char *fn;
  
    fn = bash_tilde_expand (name);
+ #if defined (__MSDOS__)
+   /* support drive name, etc */
+   fn = dosutil_expand_path (fn);
+ #endif
    if (stat (fn, &finfo) != 0)
      {
        free (fn);
***************
*** 1615,1623 ****
--- 1690,1728 ----
    int return_value = 0;
    WORD_LIST *wl;
  
+ #if defined (__MSDOS__)
+   /* support drive name, etc */
+   *dirname = dosutil_expand_path (*dirname);
+   /* may require current directory on other drive */
+   if (isalpha ((*dirname)[0]) && (*dirname)[1] == ':' && (*dirname)[2] != '/')
+     {
+       char *oldcwd, *newcwd, *fixp;
+       char newdir[3];
+ 
+       newdir[0] = (*dirname)[0];
+       newdir[1] = (*dirname)[1];
+       newdir[2] = '\0';
+       oldcwd = xmalloc (PATH_MAX);
+       newcwd = xmalloc (PATH_MAX);
+       getcwd (oldcwd, PATH_MAX);
+       chdir (newdir);
+       getcwd (newcwd, PATH_MAX);
+       chdir (oldcwd);
+       free (oldcwd);
+       fixp = xmalloc (strlen (newcwd) + 1 + (strlen (*dirname) - 2) + 1);
+       sprintf (fixp, "%s/%s", newcwd, *dirname + 2);
+       free (newcwd);
+       free (*dirname);
+       *dirname = fixp;
+     }
+ #endif
    local_dirname = *dirname;
    new_dirname = savestring (local_dirname);
+ #if defined (USE_MULTIBYTE)
+   if (_mbschr (local_dirname, '$') || _mbschr (local_dirname, '`'))
+ #else
    if (strchr (local_dirname, '$') || strchr (local_dirname, '`'))
+ #endif
      {
        wl = expand_string (new_dirname, 0);
        if (wl)
***************
*** 1665,1671 ****
--- 1770,1780 ----
            temp2[len2 + 1] = '\0';
          }
        free (local_dirname);
+ #if defined (__MSDOS__)
+       *dirname = dosutil_expand_path (temp2);
+ #else
        *dirname = temp2;
+ #endif
        free (temp1);
      }
    return (return_value);
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/braces.c bash-2.03/braces.c
*** bash203/braces.c	Fri Jul 18 16:44:42 1997
--- bash-2.03/braces.c	Fri Feb 19 17:41:46 1999
***************
*** 40,45 ****
--- 40,50 ----
  #include "general.h"
  #define brace_whitespace(c) (!(c) || (c) == ' ' || (c) == '\t' || (c) == '\n')
  
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ 
  #if defined (SHELL)
  extern char *extract_command_subst ();
  #endif
***************
*** 98,104 ****
--- 103,114 ----
  	 and I, then this should be an error.  Otherwise, it isn't. */
        for (j = start; j < i; j++)
  	{
+ #if defined (USE_MULTIBYTE)
+ 	  if (text[j] == '\\' && (j-start == 0
+ 				  || _mbsbtype (text+start, j-start) != _MBC_TRAIL))
+ #else
  	  if (text[j] == '\\')
+ #endif
  	    {
  	      j++;
  	      continue;
***************
*** 126,132 ****
--- 136,147 ----
       just return without doing any expansion.  */
    for (j = 0; amble[j]; j++)
      {
+ #if defined (USE_MULTIBYTE)
+       if (amble[j] == '\\' && (j == 0
+ 			       || _mbsbtype (amble, j) != _MBC_TRAIL))
+ #else
        if (amble[j] == '\\')
+ #endif
  	{
  	  j++;
  	  continue;
***************
*** 227,232 ****
--- 242,255 ----
  	  pass_next = 0;
  	  continue;
  	}
+ 
+ #if defined (USE_MULTIBYTE)
+       if (_ismbblead (c))
+ 	{
+ 	  pass_next = 1;
+ 	  continue;
+ 	}
+ #endif
  
        /* A backslash escapes the next character.  This allows backslash to
  	 escape the quote character in a double-quoted string. */
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/builtins/cd.def bash-2.03/builtins/cd.def
*** bash203/builtins/cd.def	Wed Jun  3 13:19:20 1998
--- bash-2.03/builtins/cd.def	Wed Jul  7 19:12:02 1999
***************
*** 49,54 ****
--- 49,58 ----
  #include "common.h"
  #include "bashgetopt.h"
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
  #if !defined (errno)
  extern int errno;
  #endif /* !errno */
***************
*** 239,247 ****
--- 243,259 ----
  
        if (absolute_pathname (dirname) == 0 && (cdpath = get_string_value ("CDPATH")))
  	{
+ #if defined (__MSDOS__)
+ 	  char *extract_unit ();
+ #endif
  	  /* Find directory in $CDPATH. */
  	  path_index = 0;
+ #if defined (__MSDOS__)
+ 	  while ((path = extract_unit (cdpath, &path_index,
+ 				       dosutil_path_separator)))
+ #else
  	  while (path = extract_colon_unit (cdpath, &path_index))
+ #endif
  	    {
  	      /* OPT is 1 if the path element is non-empty */
  	      opt = path[0] != '\0';
***************
*** 260,268 ****
  		     is used to find the directory to change to, the new
  		     directory name is echoed to stdout, whether or not
  		     the shell is interactive. */
  		  if (opt)
  		    printf ("%s\n", no_symlinks ? temp : the_current_working_directory);
! 
  		  free (temp);
  		  /* Posix.2 says that after using CDPATH, the resultant
  		     value of $PWD will not contain symlinks. */
--- 272,293 ----
  		     is used to find the directory to change to, the new
  		     directory name is echoed to stdout, whether or not
  		     the shell is interactive. */
+ #if defined (__MSDOS__)
+                      if (opt)
+                        {
+                          char *fixp = dosutil_make_import_path (no_symlinks? temp : the_current_working_directory);
+                          if (fixp != NULL)
+                            {
+                              printf ("%s\n", fixp);
+                              free (fixp);
+                            }
+                          else
+                            printf ("%s\n", temp);
+                        }
+ #else
  		  if (opt)
  		    printf ("%s\n", no_symlinks ? temp : the_current_working_directory);
! #endif
  		  free (temp);
  		  /* Posix.2 says that after using CDPATH, the resultant
  		     value of $PWD will not contain symlinks. */
***************
*** 296,302 ****
--- 321,339 ----
  	  temp = get_string_value (dirname);
  	  if (temp && change_to_directory (temp, no_symlinks))
  	    {
+ #if defined (__MSDOS__)
+ 	      char *fixp = dosutil_make_import_path (temp);
+ 	      if (fixp != NULL)
+ 		{
+ 		  printf ("%s\n", fixp);
+ 		  free (fixp);
+ 		}
+ 	      else
+ 	      printf ("%s\n", temp);
+ #else
  	      printf ("%s\n", temp);
+ #endif
+ 
  	      return (bindpwd (no_symlinks));
  	    }
  	}
***************
*** 366,372 ****
--- 403,413 ----
    if (verbatim_pwd)
      {
        buffer = xmalloc (PATH_MAX);
+ #if defined (__MSDOS__)
+       directory = dosutil_getcwd (buffer, PATH_MAX);
+ #else
        directory = getcwd (buffer, PATH_MAX);
+ #endif
  
        if (directory == 0)
  	{
***************
*** 379,384 ****
--- 420,428 ----
  
    if (directory)
      {
+ #ifdef __MSDOS__
+       directory = dosutil_expand_path (directory);
+ #endif
        printf ("%s\n", directory);
        fflush (stdout);
        free (directory);
***************
*** 427,433 ****
--- 471,481 ----
  	  tdir = t;
  	}
  
+ #if defined (__MSDOS__)
+       if (dosutil_chdir (tdir) < 0)
+ #else
        if (chdir (tdir) < 0)
+ #endif
  	{
  	  int err;
  
***************
*** 439,445 ****
--- 487,497 ----
  	  /* We failed changing to the canonicalized directory name.  Try
  	     what the user passed verbatim.  If we succeed, reinitialize
  	     the_current_working_directory. */
+ #if defined (__MSDOS__)
+ 	  if (dosutil_chdir (newdir) == 0)
+ #else
  	  if (chdir (newdir) == 0)
+ #endif
  	    {
  	      chdir_return = 1;
  	      if (the_current_working_directory)
***************
*** 459,471 ****
--- 511,547 ----
  	  chdir_return = 1;
  
  	  FREE (the_current_working_directory);
+ #if defined (__MSDOS__)
+ 	  /* get current directory if only given drive name */
+ 	  if (isalpha (tdir[0]) && tdir[1] == ':'
+ 	      && (tdir[2] != '/' || tdir[2] != '\\'))
+ 	    {
+ 	      free (tdir);
+ 	      tdir = dosutil_getcwd (NULL, PATH_MAX);
+ 	    }
+           else if (dosutil_is_encoded_drivename (tdir)
+                    && tdir[dosutil_encoded_drive_len_diff + 2] == '\0')
+ 	    {
+ 	      free (tdir);
+ 	      tdir = dosutil_getcwd (NULL, PATH_MAX);
+ 	      if (dosutil_path_separator != ':'
+ 		  && isalpha (tdir[0]) && tdir[1] == ':')
+ 		{
+                   tdir = dosutil_encode_drivename (tdir);
+ 		}
+ 	    }
+ #endif
  	  the_current_working_directory = tdir;
  	}
  
        return (chdir_return);
      }
    else
+ #if defined (__MSDOS__)
+     return (dosutil_chdir (newdir) == 0);
+ #else
      return (chdir (newdir) == 0);
+ #endif
  }
  
  /* Code for cd spelling correction.  Original patch submitted by
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/builtins/common.c bash-2.03/builtins/common.c
*** bash203/builtins/common.c	Wed Feb  4 14:56:30 1998
--- bash-2.03/builtins/common.c	Fri Feb 19 17:41:46 1999
***************
*** 63,68 ****
--- 63,72 ----
  extern int errno;   
  #endif /* !errno */
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
  extern int no_symbolic_links, interactive, interactive_shell;
  extern int indirection_level, startup_state, subshell_environment;
  extern int line_number;
***************
*** 405,411 ****
--- 409,419 ----
      {
        the_current_working_directory = xmalloc (PATH_MAX);
        the_current_working_directory[0] = '\0';
+ #if defined (__MSDOS__)
+       directory = dosutil_getcwd (the_current_working_directory, PATH_MAX);
+ #else
        directory = getcwd (the_current_working_directory, PATH_MAX);
+ #endif
        if (directory == 0)
  	{
  	  fprintf (stderr, "%s: could not get current directory: %s: %s\n",
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/builtins/evalfile.c bash-2.03/builtins/evalfile.c
*** bash203/builtins/evalfile.c	Mon Oct 13 14:47:48 1997
--- bash-2.03/builtins/evalfile.c	Thu Mar 11 13:14:18 1999
***************
*** 49,54 ****
--- 49,58 ----
  extern int errno;
  #endif
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
  /* Flags for _evalfile() */
  #define FEVAL_ENOENTOK		0x001
  #define FEVAL_BUILTIN		0x002
***************
*** 78,84 ****
--- 82,93 ----
    size_t file_size;
    VFunction *errfunc;
  
+ #if defined (__MSDOS__)
+   errno = 0;
+   fd = open (filename, O_RDONLY | O_TEXT);
+ #else
    fd = open (filename, O_RDONLY);
+ #endif
  
    if (fd < 0 || (fstat (fd, &finfo) == -1))
      {
***************
*** 118,124 ****
--- 127,138 ----
      }      
    string = xmalloc (1 + file_size);
    result = read (fd, string, file_size);
+ #if defined (__MSDOS__)
+   if (result >= 0)
+   string[result] = '\0';
+ #else
    string[result] = '\0';
+ #endif
  
    return_val = errno;
    close (fd);
***************
*** 207,212 ****
--- 221,229 ----
    int result, flags;
  
    filename = bash_tilde_expand (fname);
+ #if defined (__MSDOS__)
+   filename = dosutil_expand_path (filename);
+ #endif
    flags = FEVAL_ENOENTOK;
    if (force_noninteractive)
      flags |= FEVAL_NONINT;
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/builtins/evalstring.c bash-2.03/builtins/evalstring.c
*** bash203/builtins/evalstring.c	Tue Jan 12 12:50:14 1999
--- bash-2.03/builtins/evalstring.c	Fri Feb 19 18:11:16 1999
***************
*** 53,58 ****
--- 53,62 ----
  
  #define IS_BUILTIN(s)	(builtin_address_internal(s, 0) != (struct builtin *)NULL)
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
  extern void run_trap_cleanup ();
  
  extern int interactive, interactive_shell;
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/builtins/exec.def bash-2.03/builtins/exec.def
*** bash203/builtins/exec.def	Mon Apr 27 14:28:16 1998
--- bash-2.03/builtins/exec.def	Fri Feb 19 17:41:48 1999
***************
*** 68,73 ****
--- 68,76 ----
  
  extern int interactive, interactive_shell, subshell_environment;
  extern REDIRECT *redirection_undo_list;
+ #if defined (__MSDOS__)
+ extern int subshell_exit_builtin;
+ #endif
  
  int no_exit_on_failed_exec;
  
***************
*** 134,141 ****
--- 137,151 ----
  
    args = word_list_to_argv (list, 1, 0, (int *)NULL);
  
+ #if !defined(__MSDOS__)
    /* A command with a slash anywhere in its name is not looked up in $PATH. */
    command = absolute_program (args[0]) ? args[0] : search_for_command (args[0]);
+ #else
+   /* However, MSDOS needs to call search_for_command so it can
+      search for extensions. search_for_command does the right with
+      absolute paths, so no harm done. */
+   command = search_for_command(args[0]);
+ #endif
  
    if (command == 0)
      {
***************
*** 190,196 ****
--- 200,223 ----
      end_job_control ();
  #endif /* JOB_CONTROL */
  
+ #if defined (__MSDOS__)
+   if (!subshell_exit_builtin)
+     {
+       exit_value = shell_execve_dos (list, command, args, env, 2);
+       if (exit_value >= 0)
+ 	exit (exit_value);
+       exit_value = EXECUTION_FAILURE;
+     }
+   else
+     {
+       exit_value = shell_execve_dos (list, command, args, env, 2);
+       if (cleanenv == 0)
+ 	adjust_shell_level (1);
+       goto free_return_exit;
+     }
+ #else
    shell_execve (command, args, env);
+ #endif
  
    /* We have to set this to NULL because shell_execve has called realloc()
       to stuff more items at the front of the array, which may have caused
***************
*** 207,217 ****
--- 234,251 ----
    else
      file_error (command);
  
+ #if defined (__MSDOS__)
+ free_return_exit:
+ #endif
  failed_exec:
    if (command)
      free (command);
  
+ #if defined (__MSDOS__)
+   if (!subshell_environment && (interactive == 0 && no_exit_on_failed_exec == 0))
+ #else
    if (subshell_environment || (interactive == 0 && no_exit_on_failed_exec == 0))
+ #endif
      exit_shell (exit_value);
  
    if (args)
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/builtins/exit.def bash-2.03/builtins/exit.def
*** bash203/builtins/exit.def	Wed Nov 12 13:24:30 1997
--- bash-2.03/builtins/exit.def	Fri Feb 19 17:41:48 1999
***************
*** 47,52 ****
--- 47,57 ----
  extern int last_command_exit_value;
  extern Function *this_shell_builtin;
  extern Function *last_shell_builtin;
+ #if defined (__MSDOS__)
+ int subshell_exit_value = 0;
+ int subshell_exit_builtin = 0;
+ int subshell_skip_commands = 0;
+ #endif
  
  static int exit_or_logout ();
  static int sourced_logout;
***************
*** 124,130 ****
--- 129,141 ----
    /* Run our `~/.bash_logout' file if it exists, and this is a login shell. */
    if (login_shell && sourced_logout++ == 0)
      {
+ #if defined (__MSDOS__)
+       if (maybe_execute_file ("~/.bash_logout", 1) == 0)
+ 	if (maybe_execute_file ("~/_bash_logout", 1) == 0)
+ 	  maybe_execute_file ("~/_blogout", 1);
+ #else
        maybe_execute_file ("~/.bash_logout", 1);
+ #endif
  #ifdef SYS_BASH_LOGOUT
        maybe_execute_file (SYS_BASH_LOGOUT, 1);
  #endif
***************
*** 133,138 ****
--- 144,158 ----
    last_command_exit_value = exit_value;
  
    /* Exit the program. */
+ #if defined (__MSDOS__)
+   if (subshell_exit_builtin)
+     {
+       subshell_exit_value = exit_value;
+       subshell_exit_builtin = 0;
+       subshell_skip_commands = 1;
+       return (EXECUTION_SUCCESS);
+     }
+ #endif
    jump_to_top_level (EXITPROG);
    /*NOTREACHED*/
  }
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/builtins/hash.def bash-2.03/builtins/hash.def
*** bash203/builtins/hash.def	Thu Jan 29 14:51:26 1998
--- bash-2.03/builtins/hash.def	Fri Feb 19 17:41:48 1999
***************
*** 51,56 ****
--- 51,60 ----
  #include "common.h"
  #include "bashgetopt.h"
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
  extern int dot_found_in_search;
  extern char *this_command_name;
  
***************
*** 171,177 ****
--- 175,191 ----
  	}
  
        for ( ; item_list; item_list = item_list->next)
+ #if defined (__MSDOS__)
+ 	{
+ 	  char *fixp;
+ 
+ 	  fixp = dosutil_make_import_path (pathdata(item_list)->path);
+ 	  printf ("%4d\t%s\n", item_list->times_found, fixp);
+ 	  free (fixp);
+ 	}
+ #else
  	printf ("%4d\t%s\n", item_list->times_found, pathdata(item_list)->path);
+ #endif
  
      }
    return (any_printed);
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/builtins/history.def bash-2.03/builtins/history.def
*** bash203/builtins/history.def	Thu Jul 17 09:43:06 1997
--- bash-2.03/builtins/history.def	Fri Feb 19 17:41:48 1999
***************
*** 65,70 ****
--- 65,74 ----
  #include "bashgetopt.h"
  #include "common.h"
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
  #if !defined (errno)
  extern int errno;
  #endif
***************
*** 160,165 ****
--- 164,172 ----
      }
  
    filename = list ? list->word->word : get_string_value ("HISTFILE");
+ #if defined (__MSDOS__)
+   filename = dosutil_expand_path (savestring (filename));
+ #endif
    result = EXECUTION_SUCCESS;
  
    if (flags & AFLAG)		/* Append session's history to file. */
***************
*** 176,181 ****
--- 183,192 ----
        using_history ();
        history_lines_in_file = where_history ();
      }
+ #if defined (__MSDOS__)
+   if (filename)
+     free (filename);
+ #endif
  
    return (result ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
  }
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/builtins/psize.c bash-2.03/builtins/psize.c
*** bash203/builtins/psize.c	Fri Jul 18 16:58:52 1997
--- bash-2.03/builtins/psize.c	Fri Feb 19 17:41:48 1999
***************
*** 63,69 ****
--- 63,74 ----
    for (i = 0; i < 128; i++)
      buf[i] = ' ';
  
+ #if defined (__DJGPP__)
+   nw = 512;
+   sigpipe(0);
+ #else
    signal (SIGPIPE, sigpipe);
+ #endif
  
    nw = 0;
    for (;;)
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/builtins/psize.sh bash-2.03/builtins/psize.sh
*** bash203/builtins/psize.sh	Tue Mar 17 12:27:10 1998
--- bash-2.03/builtins/psize.sh	Mon Jun 14 11:55:38 1999
***************
*** 3,9 ****
  # psize.sh -- determine this system's pipe size, and write a define to
  #             pipesize.h so ulimit.c can use it.
  
! TMPDIR=/tmp
  TMPNAME=pipsize.$$
  TMPFILE=$TMPDIR/$TMPNAME
  
--- 3,9 ----
  # psize.sh -- determine this system's pipe size, and write a define to
  #             pipesize.h so ulimit.c can use it.
  
! TMPDIR=${TMPDIR=/tmp}
  TMPNAME=pipsize.$$
  TMPFILE=$TMPDIR/$TMPNAME
  
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/builtins/read.def bash-2.03/builtins/read.def
*** bash203/builtins/read.def	Fri Feb  5 15:34:32 1999
--- bash-2.03/builtins/read.def	Fri Feb 19 17:41:48 1999
***************
*** 64,69 ****
--- 64,74 ----
  extern int errno;
  #endif
  
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ 
  #define issep(c)	(strchr (ifs_chars, (c)))
  
  extern int interrupt_immediately;
***************
*** 218,223 ****
--- 223,237 ----
  	  pass_next = 0;
  	  continue;
  	}
+ 
+ #if defined (USE_MULTIBYTE)
+       if (_ismbblead (c))
+ 	{
+ 	  pass_next++;
+ 	  input_string[i++] = c;
+ 	  continue;
+ 	}
+ #endif
  
        if (c == '\\' && raw == 0)
  	{
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/builtins/source.def bash-2.03/builtins/source.def
*** bash203/builtins/source.def	Thu Jul 17 09:44:40 1997
--- bash-2.03/builtins/source.def	Fri Feb 19 17:41:48 1999
***************
*** 56,61 ****
--- 56,65 ----
  #include "../findcmd.h"
  #include "common.h"
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
  #if !defined (errno)
  extern int errno;
  #endif /* !errno */
***************
*** 114,123 ****
--- 118,142 ----
  #endif
  
    filename = (char *)NULL;
+ #if defined (__MSDOS__)
+   {
+     char *fixp;
+ 
+     fixp = dosutil_expand_path (savestring (list->word->word));
+     /* allocte space for dot and three extenction characters */
+     fixp = xrealloc (fixp, strlen (fixp) + 1 + 1 + 3);
+     if (source_uses_path)
+       filename = find_path_file (fixp);
+     if (filename == 0)
+       filename = savestring (fixp);
+     free (fixp);
+   }
+ #else
    if (source_uses_path)
      filename = find_path_file (list->word->word);
    if (filename == 0)
      filename = savestring (list->word->word);
+ #endif
  
    begin_unwind_frame ("source");
    add_unwind_protect ((Function *)xfree, filename);
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/builtins/type.def bash-2.03/builtins/type.def
*** bash203/builtins/type.def	Wed May 13 15:51:10 1998
--- bash-2.03/builtins/type.def	Fri Feb 19 18:12:34 1999
***************
*** 64,69 ****
--- 64,73 ----
  #include "common.h"
  #include "bashgetopt.h"
  
+ #if defined (__MSDOS__)
+ #include "../dosutil.h"
+ #endif
+ 
  extern int find_reserved_word ();
  
  /* For each word in LIST, find out what the shell is going to do with
***************
*** 216,221 ****
--- 220,228 ----
  #if defined (ALIAS)
    alias_t *alias;
  #endif
+ #if defined (__MSDOS__)
+   char *fixp = NULL;
+ #endif
  
    found = found_file = 0;
    full_path = (char *)NULL;
***************
*** 311,319 ****
--- 318,336 ----
    /* Command is a disk file? */
    /* If the command name given is already an absolute command, just
       check to see if it is executable. */
+ #if defined (__MSDOS__)
+   /* support drive name, ... */
+   fixp = dosutil_expand_path (savestring (command));
+   /* allocte space for dot and three extenction characters */
+   fixp = xrealloc (fixp, strlen (fixp) + 1 + 1 + 3);
+ #endif
    if (absolute_program (command))
      {
+ #if defined (__MSDOS__)
+       int f = file_status (fixp);
+ #else
        int f = file_status (command);
+ #endif
        if (f & FS_EXECABLE)
          {
  	  if (verbose == 1)
***************
*** 378,382 ****
--- 395,403 ----
  	break;
      }
  
+ #if defined (__MSDOS__)
+   if (fixp)
+     free (fixp);
+ #endif
    return (found);
  }
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/command.h bash-2.03/command.h
*** bash203/command.h	Tue Jan 12 12:40:32 1999
--- bash-2.03/command.h	Fri Feb 19 17:47:42 1999
***************
*** 64,69 ****
--- 64,72 ----
  #define W_GLOBEXP	0x08	/* This word is the result of a glob expansion. */
  #define W_NOSPLIT	0x10	/* Do not perform word splitting on this word. */
  #define W_NOGLOB	0x20	/* Do not perform globbing on this word. */
+ #if defined (__MSDOS__)
+ #define W_PATHEXPANSION 0x100	/* Path expansion for "/" and "/dev/x/" */
+ #endif
  
  /* Possible values for subshell_environment */
  #define SUBSHELL_ASYNC	0x01	/* subshell caused by `command &' */
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/config-bot.h bash-2.03/config-bot.h
*** bash203/config-bot.h	Thu Jul 30 11:19:36 1998
--- bash-2.03/config-bot.h	Tue Jun 29 23:46:38 1999
***************
*** 69,71 ****
--- 69,72 ----
  #if !defined (PROMPT_STRING_DECODE)
  #  define PPROMPT "$ "
  #endif
+ 
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/configure.in bash-2.03/configure.in
*** bash203/configure.in	Thu Feb 18 12:45:52 1999
--- bash-2.03/configure.in	Fri Jan 28 11:19:18 2000
***************
*** 9,15 ****
  AC_REVISION([for Bash 2.03, version 2.49, from autoconf version] AC_ACVERSION)dnl
  
  AC_INIT(shell.h)
! AC_CONFIG_HEADER(config.h)
  
  dnl make sure we are using a recent autoconf version
  AC_PREREQ(2.10)
--- 9,15 ----
  AC_REVISION([for Bash 2.03, version 2.49, from autoconf version] AC_ACVERSION)dnl
  
  AC_INIT(shell.h)
! AC_CONFIG_HEADER(config.h:config.h-in)
  
  dnl make sure we are using a recent autoconf version
  AC_PREREQ(2.10)
***************
*** 51,56 ****
--- 51,57 ----
  *-bsdi2.1|*-bsdi3.?)	opt_gnu_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
  *-beos*)	opt_gnu_malloc=no ;;	# they say it's suitable
  *-cygwin32*)	opt_gnu_malloc=no ;;	# Cygnus's CYGWIN32 environment
+ *-msdosdjgpp*)	opt_gnu_malloc=no ;;	# DJ Delorie's DJGPP
  esac
  
  dnl arguments to configure
***************
*** 93,99 ****
  	prefer_curses=yes
  fi
  
! dnl optional shell features in config.h.in
  opt_minimal_config=no
  
  opt_job_control=yes
--- 94,100 ----
  	prefer_curses=yes
  fi
  
! dnl optional shell features in config.h-in
  opt_minimal_config=no
  
  opt_job_control=yes
***************
*** 487,493 ****
  AC_TYPE_UID_T
  AC_TYPE_PID_T
  AC_TYPE_SIZE_T
! AC_CHECK_TYPE(time_t, long)
  
  AC_TYPE_SIGNAL
  
--- 488,496 ----
  AC_TYPE_UID_T
  AC_TYPE_PID_T
  AC_TYPE_SIZE_T
! dnl AC_CHECK_TYPE does not find time_t for DJGPP, so it is disabled
! dnl for a different test.
! dnl AC_CHECK_TYPE(time_t, long)
  
  AC_TYPE_SIGNAL
  
***************
*** 546,551 ****
--- 549,555 ----
  BASH_CHECK_TYPE(clock_t, [#include <sys/times.h>], long)
  BASH_CHECK_TYPE(sigset_t, [#include <signal.h>], int)
  BASH_CHECK_TYPE(quad_t, , long, HAVE_QUAD_T)
+ BASH_CHECK_TYPE(time_t, [#include <time.h>], long)
  BASH_RLIMIT_TYPE
  
  dnl presence and contents of structures used by system calls
***************
*** 681,686 ****
--- 685,699 ----
  	AC_MSG_RESULT($SHOBJ_STATUS)
  fi
  
+ #
+ # Checking for items important to DOS portability
+ #
+ 
+ ACX_CHECK_PATHNAME_STYLE_DOS
+ ACX_CHECK_DOS_FILESYS_LIMITATIONS
+ ACX_PROG_YACC_OUTPUT_ROOT
+ ACX_FUNC_FORK
+ 
  # try to create a directory tree if the source is elsewhere
  # this should be packaged into a script accessible via ${srcdir}/support
  case "$srcdir" in
***************
*** 695,701 ****
--- 708,718 ----
  	;;
  esac
  
+ if test "x$DJGPP_RELEASE" != "x"; then
+ BUILD_DIR="\${DJDIR}/gnu/bash-2.03"
+ else
  BUILD_DIR=`pwd`
+ fi
  
  AC_SUBST(PROFILE_FLAGS)
  
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/eval.c bash-2.03/eval.c
*** bash203/eval.c	Tue Jan 12 12:42:26 1999
--- bash-2.03/eval.c	Fri Feb 19 17:41:50 1999
***************
*** 137,142 ****
--- 137,145 ----
  	      executing = 1;
  	      stdin_redir = 0;
  	      execute_command (current_command);
+ #if defined (__MSDOS__)
+ 	      dosutil_pipe_clean (0);
+ #endif
  
  	    exec_done:
  	      if (current_command)
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/examples/scripts.noah/readme bash-2.03/examples/scripts.noah/readme
*** bash203/examples/scripts.noah/readme	Thu May 25 16:24:32 1995
--- bash-2.03/examples/scripts.noah/readme	Tue Jan 11 16:45:00 2000
***************
*** 8,14 ****
  Here's a description of what's in this directory:
  
  aref.bash		pseudo-arrays and substring indexing examples
! bash.sub.bash		library functions used by require.bash
  bash_version.bash	a function to slice up $BASH_VERSION
  meta.bash		enable and disable eight-bit readline input
  mktmp.bash		make a temporary file with a unique name
--- 8,14 ----
  Here's a description of what's in this directory:
  
  aref.bash		pseudo-arrays and substring indexing examples
! bash_sub.bash		library functions used by require.bash
  bash_version.bash	a function to slice up $BASH_VERSION
  meta.bash		enable and disable eight-bit readline input
  mktmp.bash		make a temporary file with a unique name
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/execute_cmd.c bash-2.03/execute_cmd.c
*** bash203/execute_cmd.c	Tue Jan 26 16:23:48 1999
--- bash-2.03/execute_cmd.c	Fri Aug  6 12:52:08 1999
***************
*** 76,82 ****
--- 76,86 ----
  
  #include "memalloc.h"
  #include "shell.h"
+ #ifndef HAVE_Y_TAB_H
  #include <y.tab.h>	/* use <...> so we pick it up from the build directory */
+ #else /* HAVE_Y_TAB_H */
+ #include <y_tab.h>
+ #endif
  #include "flags.h"
  #include "builtins.h"
  #include "hashlib.h"
***************
*** 110,115 ****
--- 114,140 ----
  #  include "bashhist.h"
  #endif
  
+ #if defined (__MSDOS__)
+ #include <stdlib.h>
+ #include <process.h>
+ #include "dosutil.h"
+ #include "trap.h"
+ #if defined (__DJGPP__)
+ #include <dpmi.h>
+ #define dup2 dosutil_dup2_wrapper
+ void __libc_termios_check_signals (void);
+ #endif
+ static int check_batch_file (char *filename);
+ static void expand_words_for_internal_command (WORD_LIST *words);
+ static void expand_arguments_for_external_command (WORD_LIST *words, char **args,
+ 						   char **except);
+ static void maybe_expand_arguments (WORD_LIST *words, char *command, char **args);
+ extern int subshell_exit_value;
+ extern int subshell_exit_builtin;
+ extern int subshell_skip_commands;
+ extern int startup_state;
+ #endif
+ 
  extern int posixly_correct;
  extern int executing, breaking, continuing, loop_level;
  extern int interactive, interactive_shell, login_shell, expand_aliases;
***************
*** 274,279 ****
--- 299,307 ----
  {
    struct fd_bitmap *bitmap;
    int result;
+ #if defined (__MSDOS__)
+   int pipes = dosutil_pipe_no ();
+ #endif
  
    current_fds_to_close = (struct fd_bitmap *)NULL;
    bitmap = new_fd_bitmap (FD_BITMAP_DEFAULT_SIZE);
***************
*** 290,295 ****
--- 318,331 ----
    unlink_fifo_list ();
  #endif /* PROCESS_SUBSTITUTION */
  
+ #if defined (__MSDOS__)
+   dosutil_pipe_clean (pipes);
+   dosutil_try_delay_remove ();
+ #if defined (__DJGPP__)
+   __libc_termios_check_signals ();
+ #endif
+ #endif
+ 
    return (result);
  }
  
***************
*** 422,427 ****
--- 458,467 ----
    REDIRECT *my_undo_list, *exec_undo_list;
    volatile pid_t last_pid;
  
+ #if defined (__MSDOS__)
+   if (subshell_skip_commands)
+     return (EXECUTION_SUCCESS);
+ #endif
    if (command == 0 || breaking || continuing || read_but_dont_execute)
      return (EXECUTION_SUCCESS);
  
***************
*** 449,462 ****
--- 489,523 ----
         (pipe_out != NO_PIPE || pipe_in != NO_PIPE || asynchronous)))
      {
        pid_t paren_pid;
+ #if defined (__MSDOS__)
+       COMMAND *old_command;
+       OLDENVBUF oldenvbuf;
+ #endif
+ 
+ #if defined (__MSDOS__)
+ 	/* save arg list */
+ 	old_command = command;
+ 	command = copy_command (old_command);
  
+ 	/* save fd, jmp_buf, current directory, global variables */
+ 	dosutil_save_all_environment (&oldenvbuf);
+ #endif
        /* Fork a subshell, turn off the subshell bit, turn off job
  	 control and call execute_command () on the command again. */
        paren_pid = make_child (savestring (make_command_string (command)),
  			      asynchronous);
+ #if defined (__MSDOS__)
+       /* force execute in parent shell */
+       if (paren_pid != 0)
+ #else
        if (paren_pid == 0)
+ #endif
  	{
  	  int user_subshell, return_code, function_value, should_redir_stdin;
+ #if defined (__MSDOS__)
+ 	  char *old_trap_list[1];
+ 	  int old_sigmodes[1];
+ #endif
  
  	  should_redir_stdin = (asynchronous && (command->flags & CMD_STDIN_REDIR) &&
  				  pipe_in == NO_PIPE &&
***************
*** 498,508 ****
--- 559,578 ----
  
  	  subshell_environment = user_subshell ? SUBSHELL_PAREN : SUBSHELL_ASYNC;
  
+ #if defined (__MSDOS__)
+ 	  /* save signal */
+ 	  old_trap_list[0] = trap_list[0] ? savestring (trap_list[0]) : NULL;
+ 	  old_sigmodes[0] = dosutil_get_signal_modes (0);
+ 
+ 	  /* Cancel exit trap */
+ 	  restore_default_signal (0);
+ #else
  	  reset_terminating_signals ();		/* in shell.c */
  	  /* Cancel traps, in trap.c. */
  	  restore_original_signals ();
  	  if (asynchronous)
  	    setup_async_signals ();
+ #endif
  
  #if defined (JOB_CONTROL)
  	  set_sigchld_handler ();
***************
*** 540,546 ****
--- 610,623 ----
  	  if (command->redirects)
  	    {
  	      if (do_redirections (command->redirects, 1, 0, 0) != 0)
+ #if defined (__MSDOS__)
+ 		{
+ 		  dosutil_wait_status = (EXECUTION_FAILURE);
+ 		  goto subshell_exit;
+ 		}
+ #else
  		exit (EXECUTION_FAILURE);
+ #endif
  
  	      dispose_redirects (command->redirects);
  	      command->redirects = (REDIRECT *)NULL;
***************
*** 567,577 ****
--- 644,672 ----
  	  if (return_catch_flag)
  	    function_value = setjmp (return_catch);
  
+ #if defined (__MSDOS__)
+ 	  begin_unwind_frame ("subshell-execute-command");
+ 	  unwind_protect_int (subshell_exit_value);
+ 	  unwind_protect_int (subshell_exit_builtin);
+ 	  unwind_protect_int (subshell_skip_commands);
+ 
+ 	  subshell_exit_value = 0;
+ 	  subshell_exit_builtin = 1;
+ 	  subshell_skip_commands = 0;
+ #endif
  	  if (function_value)
  	    return_code = return_catch_value;
  	  else
  	    return_code = execute_command_internal
  	      (command, asynchronous, NO_PIPE, NO_PIPE, fds_to_close);
+ #if defined (__MSDOS__)
+ 	  if (subshell_skip_commands)
+ 	    {
+ 	      return_code = subshell_exit_value;
+ 	      last_command_exit_value = return_code;
+ 	    }
+ 	  run_unwind_frame ("subshell-execute-command");
+ #endif
  
  	  /* If we were explicitly placed in a subshell with (), we need
  	     to do the `shell cleanup' things, such as running traps[0]. */
***************
*** 581,590 ****
--- 676,708 ----
  	      return_code = run_exit_trap ();
  	    }
  
+ #if defined (__MSDOS__)
+ 	  dosutil_wait_status = (return_code);
+ 
+ 	subshell_exit:
+ 	  /* restore signal */
+ 	  restore_default_signal (0);
+ 	  trap_list[0] = old_trap_list[0];
+ 	  dosutil_set_signal_modes (0, old_sigmodes[0]);
+ 
+ 	  /* restore fd, jmp_buf, current directory, global variables */
+ 	  dosutil_restore_all_environment (&oldenvbuf);
+ 
+ 	  /* restore arg list */
+ 	  dispose_command (command);
+ 	  command = old_command;
+ 
+ 	  goto subshell_parent;
+ #else
  	  exit (return_code);
+ #endif
  	}
        else
  	{
+ #if defined (__MSDOS__)
+ 	  /* parent side */
+ subshell_parent:
+ #endif
  	  close_pipes (pipe_in, pipe_out);
  
  #if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD)
***************
*** 620,625 ****
--- 738,747 ----
  
  	      return (EXECUTION_SUCCESS);
  	    }
+ #if defined (__MSDOS__)
+ 	  /* return in parent */
+ 	  return (0);
+ #endif
  	}
      }
  
***************
*** 726,731 ****
--- 848,859 ----
  	    if (asynchronous)
  	      {
  		DESCRIBE_PID (last_made_pid);
+ #if defined (__MSDOS__)
+ 		last_made_pid = NO_PID;
+ #if 0
+ 		last_asynchronous_pid = NO_PID;
+ #endif /* 0 */
+ #endif
  	      }
  	    else
  #if !defined (JOB_CONTROL)
***************
*** 1253,1259 ****
--- 1381,1391 ----
  	 cmd->value.Connection && cmd->value.Connection->connector == '|')
      {
        /* Make a pipeline between the two commands. */
+ #if defined (__MSDOS__)
+       if (dosutil_pipe (fildes) < 0)
+ #else
        if (pipe (fildes) < 0)
+ #endif
  	{
  	  sys_error ("pipe error");
  #if defined (JOB_CONTROL)
***************
*** 1291,1297 ****
--- 1423,1436 ----
        xbcopy ((char *)fds_to_close->bitmap, (char *)fd_bitmap->bitmap, fds_to_close->size);
  
        /* And mark the pipe file descriptors to be closed. */
+ #if defined (__MSDOS__)
+ #if 0
+       /* close pipe in */
+       fd_bitmap->bitmap[fildes[0]] = 1;
+ #endif /* 0 */
+ #else
        fd_bitmap->bitmap[fildes[0]] = 1;
+ #endif
  
        /* In case there are pipe or out-of-processes errors, we
  	 want all these file descriptors to be closed when
***************
*** 1575,1580 ****
--- 1714,1723 ----
        REAP ();
        QUIT;
  
+ #if defined (__MSDOS__)
+       if (subshell_skip_commands)
+ 	break;
+ #endif
        if (breaking)
  	{
  	  breaking--;
***************
*** 1858,1863 ****
--- 2001,2010 ----
        REAP ();
        QUIT;
  
+ #if defined (__MSDOS__)
+       if (subshell_skip_commands)
+ 	break;
+ #endif
        if (breaking)
  	{
  	  breaking--;
***************
*** 2001,2006 ****
--- 2148,2157 ----
        return_value = execute_command (while_command->test);
        REAP ();
  
+ #if defined (__MSDOS__)
+       if (subshell_skip_commands)
+ 	break;
+ #endif
        if (type == CMD_WHILE && return_value != EXECUTION_SUCCESS)
  	break;
        if (type == CMD_UNTIL && return_value == EXECUTION_SUCCESS)
***************
*** 2010,2015 ****
--- 2161,2170 ----
        body_status = execute_command (while_command->action);
        QUIT;
  
+ #if defined (__MSDOS__)
+       if (subshell_skip_commands)
+ 	break;
+ #endif
        if (breaking)
  	{
  	  breaking--;
***************
*** 2040,2045 ****
--- 2195,2204 ----
    if_command->test->flags |= CMD_IGNORE_RETURN;
    return_value = execute_command (if_command->test);
  
+ #if defined (__MSDOS__)
+   if (subshell_skip_commands)
+      return (EXECUTION_SUCCESS);
+ #endif
    if (return_value == EXECUTION_SUCCESS)
      {
        QUIT;
***************
*** 2213,2234 ****
--- 2372,2416 ----
      {
        /* We have a null command, but we really want a subshell to take
  	 care of it.  Just fork, do piping and redirections, and exit. */
+ #if defined (__MSDOS__)
+       if (make_child ((char *)NULL, async) != 0)
+ #else
        if (make_child ((char *)NULL, async) == 0)
+ #endif
  	{
+ #if !defined (__MSDOS__)
  	  /* Cancel traps, in trap.c. */
  	  restore_original_signals ();		/* XXX */
+ #endif
  
  	  do_piping (pipe_in, pipe_out);
  
  	  subshell_environment = SUBSHELL_ASYNC;
  
  	  if (do_redirections (redirects, 1, 0, 0) == 0)
+ #if defined (__MSDOS__)
+ 	    {
+ 	      dosutil_wait_status = (EXECUTION_SUCCESS);
+ 	      goto null_command_parent;
+ 	    }
+ #else
  	    exit (EXECUTION_SUCCESS);
+ #endif
  	  else
+ #if defined (__MSDOS__)
+ 	    {
+ 	      dosutil_wait_status = (EXECUTION_FAILURE);
+ 	      goto null_command_parent;
+ 	    }
+ #else
  	    exit (EXECUTION_FAILURE);
+ #endif
  	}
        else
  	{
+ #if defined (__MSDOS__)
+ 	null_command_parent:
+ #endif
  	  close_pipes (pipe_in, pipe_out);
  #if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD)
  	  unlink_fifo_list ();
***************
*** 2290,2295 ****
--- 2472,2480 ----
    pid_t old_last_command_subst_pid, old_last_async_pid;
    Function *builtin;
    SHELL_VAR *func;
+ #if defined (__MSDOS__)
+   int use_subshell = 0;
+ #endif
  
    result = EXECUTION_SUCCESS;
    special_builtin_failed = builtin_is_special = 0;
***************
*** 2325,2330 ****
--- 2510,2529 ----
  	(simple_command->words->word->word[0] == '%'))
      dofork = 0;
  
+ #if defined (__MSDOS__)
+ /* When a child is needed, set use_subshell so
+    execute_subshell_builtin_or_function is called instead of
+    execute_builtin_or_function so the bash state can be preserved.
+    Don't allow make_child to be called because piping doesn't work
+    when setup before calling the execute_subshell_* function. */
+ 
+     if (dofork)
+       {
+         use_subshell = 1;
+         dofork = 0;
+       }
+ #endif
+ 
    if (dofork)
      {
        /* XXX memory leak if expand_words() error causes a jump_to_top_level */
***************
*** 2506,2513 ****
--- 2705,2717 ----
  
    if (builtin || func)
      {
+ #if !defined (__MSDOS__)
         if (already_forked)
+ #else
+       if (use_subshell)
+ #endif
  	{
+ #if !defined (__MSDOS__)
  	  /* reset_terminating_signals (); */	/* XXX */
  	  /* Cancel traps, in trap.c. */
  	  restore_original_signals ();
***************
*** 2520,2533 ****
  		async_redirect_stdin ();
  	      setup_async_signals ();
  	    }
! 
  	  execute_subshell_builtin_or_function
  	    (words, simple_command->redirects, builtin, func,
  	     pipe_in, pipe_out, async, fds_to_close,
  	     simple_command->flags);
  	}
        else
  	{
  	  result = execute_builtin_or_function
  	    (words, builtin, func, simple_command->redirects, fds_to_close,
  	     simple_command->flags);
--- 2724,2747 ----
  		async_redirect_stdin ();
  	      setup_async_signals ();
  	    }
! #endif
! #if defined (__MSDOS__)
!           expand_words_for_internal_command (words);
! #endif
  	  execute_subshell_builtin_or_function
  	    (words, simple_command->redirects, builtin, func,
  	     pipe_in, pipe_out, async, fds_to_close,
  	     simple_command->flags);
+ #if defined (__MSDOS__)
+           result = dosutil_wait_status; 
+           goto return_result;
+ #endif
  	}
        else
  	{
+ #if defined (__MSDOS__)
+           expand_words_for_internal_command (words);
+ #endif
  	  result = execute_builtin_or_function
  	    (words, builtin, func, simple_command->redirects, fds_to_close,
  	     simple_command->flags);
***************
*** 2565,2572 ****
--- 2779,2802 ----
    execute_disk_command (words, simple_command->redirects, command_line,
  			pipe_in, pipe_out, async, fds_to_close,
  			simple_command->flags);
+ #if defined (__MSDOS__)
+ /* Set result code. */
+   result = dosutil_wait_status;
+ 
+   /* Set result code for sh -c "foo" */
+   if (startup_state == 2)
+     {
+       if ((result & 0x0000ff00) == 0x0000ff00)
+ 	result &= 0x000000ff;
+     }
+ #endif
  
   return_result:
+ #if defined (__MSDOS__)
+   if (use_subshell)
+     bind_lastarg ((char *) NULL);
+   else
+ #endif
    bind_lastarg (lastarg);
    FREE (command_line);
    run_unwind_frame ("simple-command");
***************
*** 2647,2652 ****
--- 2877,2888 ----
  
    result = ((*builtin) (words->next));
  
+ #if defined (__MSDOS__)
+   /* check subshell return */
+   if (builtin == exit_builtin && result == EXECUTION_SUCCESS)
+     result = last_command_exit_value;
+ #endif
+ 
    if (subshell == 0 && (builtin == source_builtin || builtin == eval_builtin))
      {
        /* In POSIX mode, if any variable assignments precede the `.' or
***************
*** 2784,2794 ****
--- 3020,3042 ----
  {
    int result, r, jobs_hack;
  
+ #if defined (__MSDOS__)
+   OLDENVBUF oldenvbuf;
+ #endif
+   
+ #if defined (__MSDOS__)
+   /* save fd, jmp_buf, current directory, global variables */
+   dosutil_save_all_environment (&oldenvbuf);
+ #endif
    /* A subshell is neither a login shell nor interactive. */
    login_shell = interactive = 0;
  
+ #if defined (JOBS_CONTROL)
    jobs_hack = (builtin == jobs_builtin) &&
  		((subshell_environment & SUBSHELL_ASYNC) == 0 || pipe_out != NO_PIPE);
+ #else
+   jobs_hack = 0;
+ #endif
  
    subshell_environment = SUBSHELL_ASYNC;
  
***************
*** 2816,2822 ****
--- 3064,3077 ----
      close_fd_bitmap (fds_to_close);
  
    if (do_redirections (redirects, 1, 0, 0) != 0)
+ #if defined (__MSDOS__)
+     {
+       dosutil_wait_status = (EXECUTION_FAILURE);
+       goto return_exit;
+     }
+ #else
      exit (EXECUTION_FAILURE);
+ #endif
  
    if (builtin)
      {
***************
*** 2824,2829 ****
--- 3079,3101 ----
  	 so we don't go back up to main(). */
        result = setjmp (top_level);
  
+ #if defined (__MSDOS__)
+       if (result == EXITPROG)
+ 	dosutil_wait_status = (last_command_exit_value);
+       else if (result)
+ 	dosutil_wait_status = (EXECUTION_FAILURE);
+       else
+ 	{
+ 	  r = execute_builtin (builtin, words, flags, 1);
+ 	  if (r == EX_USAGE)
+ 	    r = EX_BADUSAGE;
+ 	  dosutil_wait_status = r;
+ 	}
+     }
+   else
+     dosutil_wait_status = (execute_function (var, words, flags, fds_to_close, async, 1));
+   goto return_exit;
+ #else
        if (result == EXITPROG)
  	exit (last_command_exit_value);
        else if (result)
***************
*** 2838,2843 ****
--- 3110,3123 ----
      }
    else
      exit (execute_function (var, words, flags, fds_to_close, async, 1));
+ #endif
+ #if defined (__MSDOS__)
+  return_exit:
+   /* restore fd, jmp_buf, current directory, global variables */
+   dosutil_restore_all_environment (&oldenvbuf);
+   /* return in subshell */
+   return;
+ #endif
  }
  
  /* Execute a builtin or function in the current shell context.  If BUILTIN
***************
*** 2956,2961 ****
--- 3236,3244 ----
    char *pathname, *command, **args;
    int nofork;
    int pid;
+ #if defined (__MSDOS__)
+   int ofds[3] = { -1, -1, -1 };
+ #endif
  
    nofork = (cmdflags & CMD_NO_FORK);  /* Don't fork, just exec, if no pipes */
    pathname = words->word->word;
***************
*** 2983,2995 ****
--- 3266,3296 ----
    /* If we can get away without forking and there are no pipes to deal with,
       don't bother to fork, just directly exec the command. */
    if (nofork && pipe_in == NO_PIPE && pipe_out == NO_PIPE)
+ #if defined (__MSDOS__)
+     pid = dosutil_current_pid;
+ #else
      pid = 0;
+ #endif
    else
+ #if defined (__MSDOS__)
+     {
+       dosutil_save_std_fds (ofds);
+     pid = make_child (savestring (command_line), async);
+     }
+ #else
      pid = make_child (savestring (command_line), async);
+ #endif
  
+ #if defined (__MSDOS__)
+   if (pid != 0)
+ #else
    if (pid == 0)
+ #endif
      {
        int old_interactive;
+ #if defined (__MSDOS__)
+       int old_subshell_environment = subshell_environment;
+ #endif
  
  #if 0
        /* This has been disabled for the time being. */
***************
*** 2999,3004 ****
--- 3300,3306 ----
  #endif
  #endif
  
+ #if !defined (__MSDOS__)
        /* Cancel traps, in trap.c. */
        restore_original_signals ();
  
***************
*** 3013,3018 ****
--- 3315,3321 ----
  	    async_redirect_stdin ();
  	  setup_async_signals ();
  	}
+ #endif
  
        do_piping (pipe_in, pipe_out);
  
***************
*** 3039,3045 ****
--- 3342,3353 ----
  	     result of redirections. */
  	  unlink_fifo_list ();
  #endif /* PROCESS_SUBSTITUTION */
+ #if defined (__MSDOS__)
+ 	  dosutil_wait_status = (EXECUTION_FAILURE);
+ 	  goto return_exit;
+ #else
  	  exit (EXECUTION_FAILURE);
+ #endif
  	}
  
        if (async)
***************
*** 3048,3074 ****
        if (command == 0)
  	{
  	  internal_error ("%s: command not found", pathname);
  	  exit (EX_NOTFOUND);	/* Posix.2 says the exit status is 127 */
  	}
  
        /* Execve expects the command name to be in args[0].  So we
  	 leave it there, in the same format that the user used to
  	 type it in. */
        args = word_list_to_argv (words, 0, 0, (int *)NULL);
        exit (shell_execve (command, args, export_env));
      }
    else
      {
        /* Make sure that the pipes are closed in the parent. */
        close_pipes (pipe_in, pipe_out);
  #if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD)
        unlink_fifo_list ();
  #endif
        FREE (command);
      }
  }
  
! #if !defined (HAVE_HASH_BANG_EXEC)
  /* If the operating system on which we're running does not handle
     the #! executable format, then help out.  SAMPLE is the text read
     from the file, SAMPLE_LEN characters.  COMMAND is the name of
--- 3356,3408 ----
        if (command == 0)
  	{
  	  internal_error ("%s: command not found", pathname);
+ #if defined (__MSDOS__)
+ 	  dosutil_wait_status = (EX_NOTFOUND);
+ 	  goto return_exit;
+ #else
  	  exit (EX_NOTFOUND);	/* Posix.2 says the exit status is 127 */
+ #endif
  	}
  
        /* Execve expects the command name to be in args[0].  So we
  	 leave it there, in the same format that the user used to
  	 type it in. */
        args = word_list_to_argv (words, 0, 0, (int *)NULL);
+ #if defined (__MSDOS__)
+       dosutil_wait_status = shell_execve_dos (words, command, args, export_env, 1);
+     return_exit:
+       dosutil_restore_std_fds (ofds);
+ 
+       /* for parent shell */
+       if (nofork && pid == dosutil_current_pid)
+ 	goto disk_command_nofork;
+ 
+       /* restore parent environment */
+       subshell_environment = old_subshell_environment;
+ 
+       goto disk_command_parent;
+ #else
        exit (shell_execve (command, args, export_env));
+ #endif
      }
    else
      {
+ #if defined (__MSDOS__)
+ disk_command_parent:
+ #endif
        /* Make sure that the pipes are closed in the parent. */
        close_pipes (pipe_in, pipe_out);
  #if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD)
        unlink_fifo_list ();
  #endif
+ #if defined (__MSDOS__)
+ disk_command_nofork:
+ #endif
        FREE (command);
      }
  }
  
! #if !defined (HAVE_HASH_BANG_EXEC) || defined (__MSDOS__)
  /* If the operating system on which we're running does not handle
     the #! executable format, then help out.  SAMPLE is the text read
     from the file, SAMPLE_LEN characters.  COMMAND is the name of
***************
*** 3078,3123 ****
--- 3412,3526 ----
  
     The word immediately following the #! is the interpreter to execute.
     A single argument to the interpreter is allowed. */
+ #if defined (__MSDOS__)
+ static int
+ execute_shell_script (sample, sample_len, words, command, args, env)
+      unsigned char *sample;
+      int sample_len;
+      WORD_LIST *words;
+      char *command;
+      char **args, **env;
+ #else
  static int
  execute_shell_script (sample, sample_len, command, args, env)
       unsigned char *sample;
       int sample_len;
       char *command;
       char **args, **env;
+ #endif
  {
    register int i;
    char *execname, *firstarg;
    int start, size_increment, larry;
+ #if defined (__MSDOS__)
+   WORD_LIST *newwords;
+   char *fixp;
+   char **newargs;
+   int status;
+ #endif
  
    /* Find the name of the interpreter to exec. */
    for (i = 2; whitespace (sample[i]) && i < sample_len; i++)
      ;
  
+ #if defined (__MSDOS__)
+   /* support CR/LF */
+   for (start = i;
+        !whitespace (sample[i]) && sample[i] != '\r'
+        && sample[i] != '\n' && i < sample_len;
+        i++)
+ #else
    for (start = i;
         !whitespace (sample[i]) && sample[i] != '\n' && i < sample_len;
         i++)
+ #endif
      ;
  
    larry = i - start;
    execname = xmalloc (1 + larry);
    strncpy (execname, (char *)(sample + start), larry);
    execname[larry] = '\0';
+ #if defined (__MSDOS__)
+   /* search for suffix */
+   execname = dosutil_expand_path (execname);
+   fixp = find_user_command (execname);
+   if (fixp)
+   {
+     free (execname);
+     execname = fixp;
+   }
+ 
+   /* research without absolute pathname? */
+   if (access (execname, X_OK) != 0 && (fixp = strrchr (execname, '/')) != NULL)
+     {
+       char *execname_dos;
+       fixp++;
+       execname_dos = find_user_command (fixp);
+       if (execname_dos)
+         {
+           free (execname);
+           execname = execname_dos;
+         }
+     }
+ #endif
    size_increment = 1;
  
    /* Now the argument, if any. */
    firstarg = (char *)NULL;
+ #if defined (__MSDOS__)
+   /* support CR/LF */
+   for (start = i;
+        whitespace (sample[i]) && sample[i] != '\r'
+        && sample[i] != '\n' && i < sample_len;
+        i++)
+ #else
    for (start = i;
         whitespace (sample[i]) && sample[i] != '\n' && i < sample_len;
         i++)
+ #endif
      ;
  
    /* If there is more text on the line, then it is an argument for the
       interpreter. */
+ #if defined (__MSDOS__)
+   /* support CR/LF */
+   if (i < sample_len && sample[i] != '\r'
+       && sample[i] != '\n' && !whitespace (sample[i]))
+ #else
    if (i < sample_len && sample[i] != '\n' && !whitespace (sample[i]))
+ #endif
      {
+ #if defined (__MSDOS__)
+       /* support CR/LF */
+       for (start = i;
+ 	   !whitespace (sample[i]) && sample[i] != '\r'
+ 	   && sample[i] != '\n' && i < sample_len;
+ 	   i++)
+ #else
        for (start = i;
  	   !whitespace (sample[i]) && sample[i] != '\n' && i < sample_len;
  	   i++)
+ #endif
  	;
        larry = i - start;
        firstarg = xmalloc (1 + larry);
***************
*** 3129,3138 ****
--- 3532,3554 ----
  
    larry = array_len (args) + size_increment;
  
+ #if defined (__MSDOS__)
+   newargs = (char **)xmalloc ((1 + larry) * sizeof (char *));
+   newwords = copy_word_list (words);
+   if (firstarg)
+     newwords = make_word_list (make_word (firstarg), newwords);
+   newwords = make_word_list (make_word (execname), newwords);
+ 
+   for (i = larry - 1; i >= size_increment; i--)
+     newargs[i] = args[i - size_increment];
+ 
+   args = newargs;
+ #else
    args = (char **)xrealloc ((char *)args, (1 + larry) * sizeof (char *));
  
    for (i = larry - 1; i; i--)
      args[i] = args[i - size_increment];
+ #endif
  
    args[0] = execname;
    if (firstarg)
***************
*** 3145,3151 ****
--- 3561,3575 ----
  
    args[larry] = (char *)NULL;
  
+ #if defined (__MSDOS__)
+   status = shell_execve_dos (newwords, execname, args, env, 1);
+   dispose_words (newwords);
+   free (execname);
+   free (newargs);
+   return status;
+ #else
    return (shell_execve (execname, args, env));
+ #endif
  }
  #endif /* !HAVE_HASH_BANG_EXEC */
  
***************
*** 3188,3207 ****
--- 3612,3795 ----
  
  /* Call execve (), handling interpreting shell scripts, and handling
     exec failures. */
+ #if defined (__MSDOS__)
+ int
+ shell_execve (command, args, env)
+      char *command;
+      char **args, **env;
+ {
+   return shell_execve_dos ((WORD_LIST *)NULL, command, args, env, 0);
+ }
+ 
+ /*
+  * flag: 0 = execve, 1 = spawnve, 2 = spawnve from exec builtin,
+  */
+ int
+ shell_execve_dos (words, command, args, env, flag)
+      WORD_LIST *words;
+      char *command;
+      char **args, **env;
+      int flag;
+ #else
  int
  shell_execve (command, args, env)
       char *command;
       char **args, **env;
+ #endif
  {
    struct stat finfo;
    int larray, i, fd;
  
+ #if defined (__MSDOS__)
+   if (flag)
+     {
+       int status;
+ #if defined (__DJGPP__)
+       char oldcwd[PATH_MAX];
+       int psample_fd, psample_len = -1;
+       unsigned char psample[128];
+ 
+       /* keep cwd on exec */
+       getcwd (oldcwd, sizeof oldcwd);
+ 
+       /* read sample data */
+       if ((psample_fd = open (command, O_RDONLY)) >= 0)
+ 	{
+ 	  psample_len = read (psample_fd, &psample[0], sizeof psample);
+ 	  close (psample_fd);
+ 	}
+ 
+       /* check header before spawnXX */
+       if (psample_len < 0)
+ 	{
+ 	  file_error (command);
+ 	  return (EX_NOEXEC);
+ 	}
+       else if (psample_len == 0)
+ 	return (EXECUTION_SUCCESS);
+       else if (psample_len >= 2 && psample[0] == '#' && psample[1] == '!')
+ 	return (execute_shell_script (psample, psample_len, words, command, args, env));
+       else if (check_batch_file (command) || check_binary_file (psample, psample_len))
+ 	{
+ 	  OLDEXCEPTBUF oldexceptbuf;
+ 	  int *selectors;
+ 
+ 	  /* disable interrupt */
+ 	  int old_enable = __dpmi_get_and_disable_virtual_interrupt_state ();
+ 	  int old_ctrl_c = __djgpp_set_ctrl_c (0);
+ 
+ 	  /* check empty dpmi selectors */
+ 	  selectors = dosutil_check_dpmi_selectors ();
+ 
+ 	  /* restore old handlers */
+ 	  __djgpp_exception_toggle ();
+ 
+ #if 0
+ 	  /* save old handlers */
+ 	  dosutil_save_exceptions (&oldexceptbuf);
+ #endif
+ 
+ 	  /* expands SYSROOT, double-slashed drive name */
+ 	  maybe_expand_arguments (words, command, args);
+ 
+           /* Expand 'command'.  */
+           if (dosutil_is_encoded_drivename (command))
+             command = dosutil_decode_drivename (command);
+ 
+ 	  /* clear an error status */
+ 	  errno = 0;
+ 
+ 	  /* run child process */
+ 	  status = spawnve (P_WAIT, command, args, env);
+ 
+ 	  /* disable interrupt */
+ 	  (void) __dpmi_get_and_disable_virtual_interrupt_state ();
+ 
+ #if 0
+ 	  /* restore old handlers */
+ 	  dosutil_restore_exceptions (&oldexceptbuf);
+ #endif
+ 
+ 	  /* set new handlers */
+ 	  __djgpp_exception_toggle ();
+ 
+ 	  /* free discarded dpmi selectors */
+ 	  dosutil_free_dpmi_selectors (selectors);
+ 
+ 	  /* reset indication of standard input */
+ 	  dosutil_reset_console ();
+ 
+ 	  /* enable interrupt */
+ 	  (void) __djgpp_set_ctrl_c (old_ctrl_c);
+ #if 0
+ 	  if (old_enable)
+ #endif
+ 	    (void) __dpmi_get_and_enable_virtual_interrupt_state ();
+ 
+ 	  if (status >= 0)
+ 	    {
+ 	      /* keep cwd on exec */
+               chdir (oldcwd);
+ 	      return status;
+ 	    }
+ 	}
+       else
+ 	errno = ENOEXEC; /* may be plain text */
+ #else /* !__DJGPP__ */
+       if ((status = spawnve (P_WAIT, command, args, env)) >= 0)
+ 	return status;
+ #endif /* !__DJGPP__ */
+     }
+   else
+     execve (command, args, env);
+ #else /* !__MSDOS__ */
    SETOSTYPE (0);		/* Some systems use for USG/POSIX semantics */
    execve (command, args, env);
    SETOSTYPE (1);
+ #endif /* !__MSDOS__ */
+ 
+ #if defined (__MSDOS__) && defined (__DJGPP__)
+   /* make response file if E2BIG */
+   if (errno == E2BIG && args != NULL && args[1] != NULL && args[1][0] != '@')
+     {
+       char *tname;
+       int e = errno;
+ 
+       tname = dosutil_make_response_file (args);
+       if (tname != NULL)
+ 	{
+ 	  char *xargs[3];
+ 	  int rc;
+ 
+ 	  xargs[0] = args[0];
+ 	  xargs[1] = xmalloc (1 + strlen (tname) + 1);
+ 	  xargs[1][0] = '@';
+ 	  strcpy (&xargs[1][1], tname);
+ 	  xargs[2] = NULL;
+ 
+ 	  /* recall without expanding words */
+ 	  rc = shell_execve_dos ((WORD_LIST *)NULL, command, xargs, env, flag);
+ 
+ 	  /* cleanup */
+ 	  free (xargs[1]);
+ 	  remove (tname);
+ 	  free (tname);
+ 
+ 	  return rc;
+ 	}
+ 
+       errno = e;
+     }
+ #endif
  
    /* If we get to this point, then start checking out the file.
       Maybe it is something we can hack ourselves. */
+ #if defined (__MSDOS__)
+   /* special case */
+   if (errno == ENOENT && stat (command, &finfo) == 0
+       && !S_ISDIR (finfo.st_mode))
+     errno = ENOEXEC; /* interpreter may not find */
+ #endif
    if (errno != ENOEXEC)
      {
        i = errno;
***************
*** 3240,3248 ****
  	 characters. */
        if (sample_len > 0)
  	{
! #if !defined (HAVE_HASH_BANG_EXEC)
  	  if (sample[0] == '#' && sample[1] == '!')
  	    return (execute_shell_script (sample, sample_len, command, args, env));
  	  else
  #endif
  	  if (check_binary_file (sample, sample_len))
--- 3828,3840 ----
  	 characters. */
        if (sample_len > 0)
  	{
! #if !defined (HAVE_HASH_BANG_EXEC) || defined (__MSDOS__)
  	  if (sample[0] == '#' && sample[1] == '!')
+ #if defined (__MSDOS__)
+ 	    return (execute_shell_script (sample, sample_len, words, command, args, env));
+ #else /* !__MSDOS__ */
  	    return (execute_shell_script (sample, sample_len, command, args, env));
+ #endif /* !__MSDOS__ */
  	  else
  #endif
  	  if (check_binary_file (sample, sample_len))
***************
*** 3253,3261 ****
--- 3845,3855 ----
  	}
      }
  
+ #if !defined (__MSDOS__)
    initialize_subshell ();
  
    set_sigint_handler ();
+ #endif
  
    /* Insert the name of this shell into the argument list. */
    larray = array_len (args) + 1;
***************
*** 3271,3276 ****
--- 3865,3985 ----
    if (args[0][0] == '-')
      args[0]++;
  
+ #if defined (__MSDOS__)
+   if (flag)
+     {
+       int status;
+ #if defined (__DJGPP__)
+       char oldcwd[PATH_MAX];
+ 
+       /* keep cwd on exec */
+       getcwd (oldcwd, sizeof oldcwd);
+ 
+       {
+ 	OLDEXCEPTBUF oldexceptbuf;
+ 	int *selectors;
+ 
+ 	/* disable interrupt */
+ 	int old_enable = __dpmi_get_and_disable_virtual_interrupt_state ();
+ 	int old_ctrl_c = __djgpp_set_ctrl_c (0);
+ 
+ 	/* check empty dpmi selectors */
+ 	selectors = dosutil_check_dpmi_selectors ();
+ 
+ 	/* restore old handlers */
+ 	__djgpp_exception_toggle ();
+ 
+ 	/* save old handlers */
+ 	dosutil_save_exceptions (&oldexceptbuf);
+ 
+ 	/* clear an error status */
+ 	errno = 0;
+ 
+ 	/* run child process */
+ 	status = spawnve (P_WAIT, shell_name, args, env);
+ 
+ 	/* disable interrupt */
+ 	(void) __dpmi_get_and_disable_virtual_interrupt_state ();
+ 
+ 	/* restore old handlers */
+ 	dosutil_restore_exceptions (&oldexceptbuf);
+ 
+ 	/* set new handlers */
+ 	__djgpp_exception_toggle ();
+ 
+ 	/* free discarded dpmi selectors */
+ 	dosutil_free_dpmi_selectors (selectors);
+ 
+ 	/* reset indication of standard input */
+ 	dosutil_reset_console ();
+ 
+ 	/* enable interrupt */
+ 	(void) __djgpp_set_ctrl_c (old_ctrl_c);
+ #if 0
+ 	if (old_enable)
+ #endif
+ 	  (void) __dpmi_get_and_enable_virtual_interrupt_state ();
+ 
+ 	if (status >= 0)
+ 	  {
+ 	    /* keep cwd on exec */
+ 
+             chdir (oldcwd);
+ 	    return status;
+ 	  }
+       }
+ #else /* !__DJGPP__ */
+       if ((status = spawnve (P_WAIT, shell_name, args, env)) >= 0)
+ 	return status;
+ #endif /* !__DJGPP__ */
+     }
+   else
+     execve (shell_name, args, env);
+ 
+ #if defined (__DJGPP__)
+   /* make response file if E2BIG */
+   if (errno == E2BIG && args != NULL && args[1] != NULL && args[1][0] != '@')
+     {
+       char *tname;
+       int e = errno;
+ 
+       tname = dosutil_make_response_file (args);
+       if (tname != NULL)
+ 	{
+ 	  char *xargs[3];
+ 	  int rc;
+ 
+ 	  xargs[0] = args[0];
+ 	  xargs[1] = xmalloc (1 + strlen (tname) + 1);
+ 	  xargs[1][0] = '@';
+ 	  strcpy (&xargs[1][1], tname);
+ 	  xargs[2] = NULL;
+ 
+ 	  /* recall without expanding words */
+ 	  rc = shell_execve_dos ((WORD_LIST *)NULL, command, xargs, env, flag);
+ 
+ 	  /* cleanup */
+ 	  free (xargs[1]);
+ 	  remove (tname);
+ 	  free (tname);
+ 	  return rc;
+ 	}
+       errno = e;
+     }
+ #endif
+ 
+   /* cannot run a plain script... */
+   if ((stat (command, &finfo) == 0) && (S_ISDIR (finfo.st_mode)))
+     internal_error ("%s: is a directory", command);
+   else
+     file_error (command);
+ 
+   /* from exec?, then return minus number */
+   if (flag == 2)
+     return -1;
+   /* never run below */
+   return (EXECUTION_FAILURE);
+ #else /* !__MSDOS__ */
  #if defined (RESTRICTED_SHELL)
    if (restricted)
      change_flag ('r', FLAG_OFF);
***************
*** 3294,3299 ****
--- 4003,4009 ----
    unbind_args ();	/* remove the positional parameters */
  
    longjmp (subshell_top_level, 1);
+ #endif /* !__MSDOS__ */
  }
  
  static int
***************
*** 3366,3371 ****
--- 4076,4085 ----
  #ifdef __CYGWIN32__
        setmode (0, O_TEXT);
  #endif
+ #if defined (__MSDOS__)
+       /* reset file pointer */
+       lseek (0, 0, SEEK_SET);
+ #endif
      }
    if (pipe_out != NO_PIPE)
      {
***************
*** 3390,3392 ****
--- 4104,4236 ----
  	}
      }
  }
+ 
+ #if defined (__MSDOS__)
+ static int
+ check_batch_file (char *filename)
+ {
+   int len;
+ 
+   if ((len = strlen (filename)) > 4)
+     if ((filename[len - 4] == '.')
+ 	&& (filename[len - 3] == 'B' || filename[len - 3] == 'b')
+ 	&& (filename[len - 2] == 'A' || filename[len - 2] == 'a')
+ 	&& (filename[len - 1] == 'T' || filename[len - 1] == 't'))
+       return 1;
+ 
+   return 0;
+ }
+ 
+ static void
+ expand_words_for_internal_command (WORD_LIST *words)
+ {
+   char *p;
+ 
+   if (!dosutil_path_expand || words == NULL)
+     return;
+ 
+   words = words->next; /* skip command name */
+   while (words)
+     {
+       p = words->word->word;
+       if (words->word->flags & W_PATHEXPANSION)
+ 	{
+ 	  /* nothing */
+ 	}
+       words->word->word = p;
+       words = words->next;
+     }
+ }
+ 
+ static void
+ expand_arguments_for_external_command (WORD_LIST *words, char **args, char **except)
+ {
+   char *p;
+   int i;
+ 
+   if (!dosutil_path_expand || words == NULL || args == NULL || *args == NULL)
+     return;
+ 
+   args++; /* skip command name */
+   words = words->next;
+   while ((p = *args) != NULL)
+     {
+       /* may skip argument */
+       if (except != NULL)
+ 	{
+ 	  if (strnicmp (p, "--", sizeof ("--") - 1) == 0)
+ 	    {
+ 	      except = NULL; /* terminate switch */
+ 	      args++;
+ 	      goto done;
+ 	    }
+ 
+ 	  for (i = 1; except[i] != NULL; i++)
+ 	    {
+ 	      if (strnicmp (p, except[i], strlen (except[i])) == 0)
+ 		{
+ 		skip_args:
+ 		  args++;
+ 		  if (*args != NULL) /* skip only complete argument */
+ 		    {
+ 		      words = words->next;
+ 		      args++;
+ 		    }
+ 		  goto done;
+ 		}
+ 	    }
+ 	}
+ 
+       /* expands only non-quoted string */
+       if (words->word->flags & W_PATHEXPANSION)
+         words->word->word = p = dosutil_expand_path (p);
+ 
+       /* stores and increases */
+       *args++ = p;
+     done:
+       words = words->next;
+     }
+ }
+ 
+ static void
+ maybe_expand_arguments (WORD_LIST *words, char *command, char **args)
+ {
+   static char *except_sed[] = { "sed", "-e", NULL };
+   static char *except_gsed[] = { "gsed", "-e", NULL };
+   static char **except_array[] =
+     {
+       except_sed,
+       except_gsed,
+       NULL
+     };
+   static char *shells[] = { "bash", "sh", NULL };
+   char **except = NULL, *fixp, *p;
+   int i, need_expand = 1;
+ 
+   if (!dosutil_path_expand || words == NULL || command == NULL
+       || args == NULL || *args == NULL)
+     return;
+ 
+   fixp = savestring (command);
+   dosutil_toslash (fixp);
+   if ((p = strrchr (fixp, '/')) == NULL)
+     p = fixp - 1;
+   p++;
+   for (i = 0; shells[i] != NULL; i++)
+     if (strnicmp (p, shells[i], strlen (shells[i])) == 0)
+       {
+ 	need_expand = 0;
+ 	break;
+       }
+   if (need_expand)
+     {
+       for (i = 0; except_array[i] != NULL; i++)
+ 	if (strnicmp (p, except_array[i][0], strlen (except_array[i][0])) == 0)
+ 	  except = except_array[i];
+     }
+   free (fixp);
+ 
+   if (need_expand)
+     expand_arguments_for_external_command (words, args, except);
+ }
+ #endif
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/execute_cmd.h bash-2.03/execute_cmd.h
*** bash203/execute_cmd.h	Thu Jul 10 12:29:38 1997
--- bash-2.03/execute_cmd.h	Fri Feb 19 17:41:52 1999
***************
*** 37,40 ****
--- 37,44 ----
  extern void close_all_files __P((void));
  #endif
  
+ #if defined (__MSDOS__)
+ extern int shell_execve_dos __P((WORD_LIST *, char *, char **, char **, int));
+ #endif
+ 
  #endif /* _EXECUTE_CMD_H_ */
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/findcmd.c bash-2.03/findcmd.c
*** bash203/findcmd.c	Wed Oct 15 11:55:20 1997
--- bash-2.03/findcmd.c	Mon Aug  9 00:11:42 1999
***************
*** 47,52 ****
--- 47,64 ----
  #include "pathexp.h"
  #include "hashcmd.h"
  
+ #if defined (__MSDOS__)
+ #include <stdlib.h>
+ #include <process.h>
+ #include "dosutil.h"
+ #include "trap.h"
+ #if defined (__DJGPP__)
+ #include <dpmi.h>
+ #define dup2 dosutil_dup2_wrapper
+ /* void __libc_termios_check_signals (void); */
+ #endif
+ #endif
+ 
  extern int posixly_correct;
  
  /* Static functions defined and used in this file. */
***************
*** 75,80 ****
--- 87,145 ----
  #define o_mode_bits(x) (((x) & 0000007) >> 0)
  #define X_BIT(x) ((x) & 1)
  
+ #ifdef __MSDOS__
+ 
+ /* Most of the functions here duplicate ones available in DJGPP's libc.
+    But the code makes it inpracticle without even more surgery. */
+ 
+ static const char *special_dirs[] =
+ {
+   "/bin/",
+   "/usr/",
+   NULL,
+ };
+ 
+ int prog_in_special_dir (char *prog)
+ {
+   int index;
+   for (index = 0; special_dirs[index] != NULL; index++)
+   {
+     /* Should special_dirs ever have have strings of different lengths,
+        the third paramter will need to change. */
+     if (strnicmp(special_dirs[index], prog, sizeof("/bin/")-1) == 0)
+       return 1;
+   }
+   
+   return 0;
+ }
+ 
+ int special_dir_exists (char *prog, char **name_start)
+ {
+   char ch;
+   int result;
+   char *ch_save = strrchr (prog, '/');
+ 
+   if (name_start)
+     *name_start = NULL;
+ 
+   if (!ch_save)
+     return 0;
+ 
+   ch_save++;
+ 
+   if (name_start)
+     *name_start = ch_save;
+ 
+   ch = *ch_save;
+   *ch_save = '\0';
+   result = (access (prog, D_OK) == 0);
+   *ch_save = ch;
+ 
+   return result;
+ }
+   
+ #endif
+ 
  /* Return some flags based on information about this file.
     The EXISTS bit is non-zero if the file is found.
     The EXECABLE bit is non-zero the file is executble.
***************
*** 135,140 ****
--- 200,212 ----
    if (X_BIT (o_mode_bits (finfo.st_mode)))
      return (FS_EXISTS | FS_EXECABLE);
  
+ #if defined (__MSDOS__)
+   /* If we got here, then we don't have an EXE. See if we have
+      some type of a script before giving it up. */
+   if (dosutil_has_executable_suffix (name))
+     return (FS_EXISTS | FS_EXECABLE);
+ #endif
+ 
    return (FS_EXISTS);
  #endif /* !AFS */
  }
***************
*** 241,247 ****
--- 313,323 ----
  {
    char *path;
  
+ #if defined (__MSDOS__)
+   path = extract_unit (path_list, path_index_pointer, dosutil_path_separator);
+ #else
    path = extract_colon_unit (path_list, path_index_pointer);
+ #endif
  
    if (!path)
      return (path);
***************
*** 265,273 ****
--- 341,353 ----
    char *hashed_file, *command;
    int temp_path, st;
    SHELL_VAR *path;
+ #if defined (__MSDOS__)
+   char *fixp = NULL;
+ #endif
  
    hashed_file = command = (char *)NULL;
  
+ 
    /* If PATH is in the temporary environment for this command, don't use the
       hash table to search for the full pathname. */
    path = find_tempenv_variable ("PATH");
***************
*** 276,282 ****
--- 356,367 ----
    /* Don't waste time trying to find hashed data for a pathname
       that is already completely specified or if we're using a command-
       specific value for PATH. */
+ #ifndef __MSDOS__
    if (path == 0 && absolute_program (pathname) == 0)
+ #else
+   if (path == 0 && (absolute_program (pathname) == 0 || prog_in_special_dir (pathname)))
+ #endif
+ 
      hashed_file = find_hashed_filename (pathname);
  
    /* If a command found in the hash table no longer exists, we need to
***************
*** 296,320 ****
  
    if (hashed_file)
      command = hashed_file;
-   else if (absolute_program (pathname))
-     /* A command containing a slash is not looked up in PATH or saved in
-        the hash table. */
-     command = savestring (pathname);
    else
      {
        /* If $PATH is in the temporary environment, we've already retrieved
! 	 it, so don't bother trying again. */
        if (temp_path)
          {
! 	  command = find_user_command_in_path (pathname, value_cell (path),
  					       FS_EXEC_PREFERRED|FS_NODIRS);
! 	  if (tempvar_p (path))
! 	    dispose_variable (path);
          }
        else
! 	command = find_user_command (pathname);
        if (command && hashing_enabled && temp_path == 0)
  	remember_filename (pathname, command, dot_found_in_search, 1);
      }
    return (command);
  }
--- 381,474 ----
  
    if (hashed_file)
      command = hashed_file;
    else
      {
+       /* A non-faulty Unix installation will have a /bin directory.
+          The closest equivalent for DOS would be the searching the path.
+          Therefore, if a command in the /bin directory isn't found under
+          DOS, search again through the PATH.  */
+ 
+ #if defined (__MSDOS__)
+       int is_special_path = 0;
+       char *pathname_save = NULL;
+       char *name_loc = NULL;
+       fixp = NULL;
+ #endif
+       command = NULL;
+ 
+       if (absolute_program (pathname))
+         {
+ #if !defined (__MSDOS__)
+           /* A command containing a slash is not looked up in PATH or
+              saved in the hash table. */
+           command = savestring (pathname);
+           return command;
+ #else
+           /* Find out if pathname starts with '/bin/' */
+           static int check_special_dir = -1;
+           is_special_path = prog_in_special_dir (pathname);
+           fixp = dosutil_expand_path (savestring (pathname));
+           if (is_special_path)
+             {
+               /* Find out if the special directory exists while taking
+                  SYSROOT into account. If we don't find it the first time,
+                  don't keep checking over and over.  */
+               if (check_special_dir == -1)
+                 check_special_dir = special_dir_exists (fixp, &name_loc);
+             }
+ 
+           /* If path doesn't include a 'special' directory
+              or if the path does includes the 'special' directory
+              but the directory doesn't exist,
+              then skip the find attempt. */
+           if (!is_special_path || check_special_dir)
+               command = find_absolute_program (fixp, FS_EXISTS | FS_NODIRS);
+ 
+           /* Return if a command was found
+              or if not searching a special directory. */
+           if (command || !is_special_path)
+             {
+               free (fixp);
+               return (command);
+             }
+ #endif
+         }
+ 
+ #if defined (__MSDOS__)
+       if (is_special_path)
+         {
+           /* Save away the pathname so that it might
+              be stored in a hash table later. */
+           pathname_save = pathname;
+           /* Skip past the directories. */
+           pathname = name_loc;
+         }
+ #endif
        /* If $PATH is in the temporary environment, we've already retrieved
!          it, so don't bother trying again. */
! 
        if (temp_path)
          {
!           command = find_user_command_in_path (pathname, value_cell (path),
  					       FS_EXEC_PREFERRED|FS_NODIRS);
!           if (tempvar_p (path))
!             dispose_variable (path);
          }
        else
!         command = find_user_command (pathname);
! 
! #if defined (__MSDOS__)
!       if (pathname_save)
!         pathname = pathname_save;
! #endif
! 
        if (command && hashing_enabled && temp_path == 0)
  	remember_filename (pathname, command, dot_found_in_search, 1);
+ 
+ #if defined (__MSDOS__)
+       if (fixp)
+         free (fixp);
+ #endif
      }
    return (command);
  }
***************
*** 413,421 ****
    int path_len;
  
    path_len = strlen (path);
    full_path = xmalloc (2 + path_len + name_len);
    strcpy (full_path, path);
!   full_path[path_len] = '/';
    strcpy (full_path + path_len + 1, name);
    return (full_path);
  }
--- 567,583 ----
    int path_len;
  
    path_len = strlen (path);
+ #if defined (__MSDOS__)
+   /* for adding extension (dot + 3ext) */
+   full_path = xmalloc (2 + path_len + name_len + 1 + 3);
+ #else
    full_path = xmalloc (2 + path_len + name_len);
+ #endif
    strcpy (full_path, path);
!   if (full_path[path_len - 1] != '/')
!     full_path[path_len] = '/';
!   else
!     --path_len;
    strcpy (full_path + path_len + 1, name);
    return (full_path);
  }
***************
*** 426,443 ****
       int flags;
  {
    int st;
  
    st = file_status (name);
  
    /* If the file doesn't exist, quit now. */
!   if ((st & FS_EXISTS) == 0)
      return ((char *)NULL);
  
    /* If we only care about whether the file exists or not, return
       this filename.  Otherwise, maybe we care about whether this
       file is executable.  If it is, and that is what we want, return it. */
    if ((flags & FS_EXISTS) || ((flags & FS_EXEC_ONLY) && (st & FS_EXECABLE)))
      return (savestring (name));
  
    return ((char *)NULL);
  }
--- 588,628 ----
       int flags;
  {
    int st;
+ #if defined (__MSDOS__)
+   char *fixp = NULL;
+ #endif
  
+ #if defined (__MSDOS__)
+   /* for adding extention (dot + 3ext) */
+   fixp = xmalloc (1 + strlen(name) + 1 + 3);
+   strcpy (fixp, name);
+   dosutil_add_executable_suffix (fixp);
+   st = file_status (fixp);
+ #else
    st = file_status (name);
+ #endif
  
    /* If the file doesn't exist, quit now. */
!   if ((st & FS_EXISTS) == 0 || (st & FS_DIRECTORY))
! #if defined (__MSDOS__)
!     {
!       free(fixp);
!       return ((char *)NULL);
!     }
! #else
      return ((char *)NULL);
+ #endif
  
    /* If we only care about whether the file exists or not, return
       this filename.  Otherwise, maybe we care about whether this
       file is executable.  If it is, and that is what we want, return it. */
+ #if !defined (__MSDOS__)
    if ((flags & FS_EXISTS) || ((flags & FS_EXEC_ONLY) && (st & FS_EXECABLE)))
      return (savestring (name));
+ #else
+   if ((flags & (FS_EXISTS | FS_EXEC_PREFERRED)) || ((flags & FS_EXEC_ONLY) && (st & FS_EXECABLE)))
+     return fixp;
+ #endif
  
    return ((char *)NULL);
  }
***************
*** 460,465 ****
--- 645,653 ----
  
    full_path = make_full_pathname (xpath, name, name_len);
  
+ #ifdef __MSDOS__
+   dosutil_add_executable_suffix (full_path);
+ #endif
    status = file_status (full_path);
  
    if (xpath != path)
***************
*** 524,529 ****
--- 712,722 ----
    char *full_path, *path;
    int path_index, name_len;
    struct stat dotinfo;
+ #if defined (__MSDOS)
+   char *fixp = NULL;
+   int is_special_path = 0;
+   char *name_loc = 0;
+ #endif
  
    /* We haven't started looking, so we certainly haven't seen
       a `.' as the directory path yet. */
***************
*** 531,539 ****
--- 724,743 ----
  
    if (absolute_program (name))
      {
+       int check_special_dir = 0;
+       is_special_path = prog_in_special_dir (name);
+       check_special_dir = (is_special_path) ? special_dir_exists (name, &name_loc) : 0;
+       if (!is_special_path || check_special_dir)
        full_path = find_absolute_program (name, flags);
+       else
+         full_path = NULL;
+ 
+       if (!is_special_path || full_path)
        return (full_path);
      }
+ 
+   if (is_special_path)
+     name = name_loc;
  
    if (path_list == 0 || *path_list == '\0')
      return (savestring (name));		/* XXX */
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/general.c bash-2.03/general.c
*** bash203/general.c	Tue Dec  1 16:05:48 1998
--- bash-2.03/general.c	Sat Aug 14 18:16:28 1999
***************
*** 54,59 ****
--- 54,69 ----
  #include <sys/times.h>
  #include "maxpath.h"
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #define dup2 dosutil_dup2_wrapper
+ #endif
+ 
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ 
  #if !defined (errno)
  extern int errno;
  #endif /* !errno */
***************
*** 427,432 ****
--- 437,443 ----
  move_to_high_fd (fd, check_new, maxfd)
       int fd, check_new, maxfd;
  {
+ #if !defined (__DJGPP__)
    int script_fd, nfds, ignore;
  
    if (maxfd < 20)
***************
*** 450,456 ****
  	close (fd);
        return (script_fd);
      }
! 
    return (fd);
  }
   
--- 461,474 ----
  	close (fd);
        return (script_fd);
      }
! #else
!   int new_fd = fcntl (fd, F_DUPFD, 20);
!   if (new_fd >= 0)
!     {
!       close (fd);
!       fd = new_fd;
!     }
! #endif
    return (fd);
  }
   
***************
*** 474,479 ****
--- 492,504 ----
  {
    register int i;
  
+ #if defined (__DJGPP__)
+   if (sample_len >= 2
+       && ((sample[0] == 'M' && sample[1] == 'Z') /* exe type */
+ 	  || (sample[0] == 0x4c && sample[1] == 0x01))) /* coff type */
+     return 1;
+ #endif
+ 
    for (i = 0; i < sample_len; i++)
      {
        if (sample[i] == '\n')
***************
*** 527,532 ****
--- 552,570 ----
    char stub_char;
    char *result;
  
+ #if defined (__MSDOS__) && 0
+   if (path[0] == '/' && dosutil_sysroot_len <= 0)
+     {
+       unsigned int drive;
+       result = xmalloc (strlen(path) + 3);
+       strcpy (result + 2, path);
+       _dos_getdrive(&drive);
+       result[0] = drive + 'A' - 1;
+       result[1] = ':';
+     }
+   else
+ #endif
+ 
    /* The result cannot be larger than the input PATH. */
    result = savestring (path);
  
***************
*** 534,539 ****
--- 572,585 ----
  
    /* Walk along RESULT looking for things to compact. */
    i = 0;
+ #if defined (__MSDOS__)
+   /* skip drive name */
+   if (isalpha (result[0]) && result[1] == ':')
+     {
+       i += 2;
+       stub_char = (result[2] == '/') ? '/' : '.';
+     }
+ #endif
    while (1)
      {
        if (!result[i])
***************
*** 552,558 ****
        while (result[i] == '/')
  	i++;
  
! #if 0
        if ((start + 1) != i)
  #else
        /* Leave a leading `//' alone, as POSIX requires. */
--- 598,604 ----
        while (result[i] == '/')
  	i++;
  
! #if 0 || defined (__MSDOS__)
        if ((start + 1) != i)
  #else
        /* Leave a leading `//' alone, as POSIX requires. */
***************
*** 563,569 ****
--- 609,619 ----
  	  i = start + 1;
  	  /* Make sure that what we have so far corresponds to a directory.
  	     If it does not, just punt. */
+ #if defined (__MSDOS__)
+           if (*result && !(start == 2 && result[1] == ':'))
+ #else
  	  if (*result)
+ #endif
  	    {
  	      char c;
  	      c = result[start];
***************
*** 578,590 ****
--- 628,650 ----
  	}
  #if 0
        /* Handle backslash-quoted `/'. */
+ #if defined (USE_MULTIBYTE)
+       if (start > 0 && result[start - 1] == '\\'
+ 	  && _mbsbtype (result, start-1) != _MBC_TRAIL)
+ #else
        if (start > 0 && result[start - 1] == '\\')
+ #endif
  	continue;
  #endif
  
        /* Check for trailing `/'. */
        if (start && !result[i])
  	{
+ #if defined (__MSDOS__)
+           /* Don't strip '/' from x:/ or /dev/x/  */
+           if (dosutil_is_root_directory_pathname (result))
+             break;
+ #endif
  	zero_last:
  	  result[--i] = '\0';
  	  break;
***************
*** 633,638 ****
--- 693,724 ----
  	      i = (start < 0) ? 0 : start;
  	      continue;
  	    }
+ #if defined (__MSDOS__)
+ 	  /* Handle triple or more dots (Win95 compatible) */
+ 	  {
+ 	    int n = i + 1, pos;
+ 
+ 	    while (result[n] == '.')
+ 	      n++;
+ 	    if (result[n] == '\0' || result[n] == '/')
+ 	      {
+ 		pos = n; /* current position */
+ 		n -= i + 1; /* number of dots - 1 */
+ 		/* .... -> ../../.. */
+ 		while (--n >= 0)
+ 		  {
+ 		    if (start < 0)
+ 		      break;
+ 		    /* search for prev. slash */
+ 		    while (--start > -1 && result[start] != '/')
+ 		      ;
+ 		  }
+ 		strcpy (result + start + 1, result + pos);
+ 		i = (start < 0) ? 0 : start;
+ 		continue;
+ 	      }
+ 	  }
+ #endif
  	}
      }
  
***************
*** 672,681 ****
--- 758,786 ----
    char *result;
    int result_len;
  
+ #if defined (__MSDOS__)
+   if (dot_path == 0 || *string == '/' || (isalpha (*string) && string[1] == ':'))
+ #else
    if (dot_path == 0 || *string == '/')
+ #endif
      result = savestring (string);
    else
      {
+ #if defined (__MSDOS__)
+       if (dot_path[0] == '/'
+           && dosutil_sysroot_len > 0)
+         {
+           int s_len = strlen (dot_path);
+           result = xmalloc (2 + dosutil_sysroot_len + s_len + strlen(string));
+           result_len = dosutil_sysroot_len;
+           strcpy (result, dosutil_sysroot);
+           strcpy (result + result_len, dot_path);
+           result_len += s_len;
+           result[result_len] = '/';
+           ++result_len;
+         }
+       else
+ #endif
        if (dot_path[0])
  	{
  	  result_len = strlen (dot_path);
***************
*** 708,714 ****
--- 813,823 ----
    if (!string || !*string)
      return (0);
  
+ #if defined (__MSDOS__)
+   if (*string == '/' || (isalpha (*string) && string[1] == ':'))
+ #else
    if (*string == '/')
+ #endif
      return (1);
  
    if (*string++ == '.')
***************
*** 716,721 ****
--- 825,837 ----
        if (!*string || *string == '/' ||
  	   (*string == '.' && (string[1] == '\0' || string[1] == '/')))
  	return (1);
+ #if defined (__MSDOS__)
+       /* pass triple or more dots (Win95 compatible) */
+       while (*string == '.')
+ 	string++;
+       if (*string == '\0' || *string == '/')
+ 	return (1);
+ #endif
      }
    return (0);
  }
***************
*** 727,732 ****
--- 843,852 ----
  absolute_program (string)
       char *string;
  {
+ #ifdef HAVE_PATHNAME_STYLE_DOS
+   if (string && string[1] == ':')
+     return (string[2] ? 1 : 0);
+ #endif
    return ((char *)strchr (string, '/') != (char *)NULL);
  }
  
***************
*** 759,772 ****
--- 879,900 ----
  
    file = (*file == '~') ? bash_tilde_expand (file) : savestring (file);
  
+ #if defined (__MSDOS__)
+   if (absolute_pathname (file))
+ #else
    if ((*file == '/') && absolute_pathname (file))
+ #endif
      return (file);
  
    disposer = file;
  
    /* XXX - this should probably be just PATH_MAX or PATH_MAX + 1 */
    current_dir = xmalloc (2 + PATH_MAX + strlen (file));
+ #if defined (__MSDOS__)
+   if (dosutil_getcwd (current_dir, PATH_MAX) == 0)
+ #else
    if (getcwd (current_dir, PATH_MAX) == 0)
+ #endif
      {
        sys_error (bash_getcwd_errstr);
        free (disposer);
***************
*** 815,824 ****
--- 943,968 ----
  /* Given a string containing units of information separated by colons,
     return the next one pointed to by (P_INDEX), or NULL if there are no more.
     Advance (P_INDEX) to the character after the colon. */
+ #if defined (__MSDOS__)
+ char *
+ extract_colon_unit (string, p_index)
+      char *string;
+      int *p_index;
+ {
+   return extract_unit (string, p_index, ':');
+ }
+ 
+ char *
+ extract_unit (string, p_index, separator)
+      char *string;
+      int *p_index;
+      int separator;
+ #else
  char *
  extract_colon_unit (string, p_index)
       char *string;
       int *p_index;
+ #endif
  {
    int i, start, len;
    char *value;
***************
*** 837,846 ****
--- 981,998 ----
       `:'.  If I is 0, then the path has a leading colon.  Trailing colons
       are handled OK by the `else' part of the if statement; an empty
       string is returned in that case. */
+ #if defined (__MSDOS__)
+   if (i && string[i] == separator)
+ #else
    if (i && string[i] == ':')
+ #endif
      i++;
  
+ #if defined (__MSDOS__)
+   for (start = i; string[i] && string[i] != separator; i++)
+ #else
    for (start = i; string[i] && string[i] != ':'; i++)
+ #endif
      ;
  
    *p_index = i;
***************
*** 859,864 ****
--- 1011,1019 ----
        value = xmalloc (1 + len);
        strncpy (value, string + start, len);
        value [len] = '\0';
+ #if defined (__MSDOS__)
+       value = dosutil_expand_path (value);
+ #endif
      }
  
    return (value);
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/general.h bash-2.03/general.h
*** bash203/general.h	Tue May  5 13:12:06 1998
--- bash-2.03/general.h	Fri Feb 19 17:41:54 1999
***************
*** 70,75 ****
--- 70,80 ----
  #  define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x))
  #endif
  
+ /* Added for DJGPP port. */
+ #if !defined (save_filename_string)
+ #  define save_filename_string(x) (char *)strcpy (xmalloc (1 + strlen (x) + 4), (x))
+ #endif
+ 
  #ifndef member
  #  define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
  #endif
***************
*** 215,220 ****
--- 220,228 ----
  extern char *polite_directory_format __P((char *));
  
  extern char *extract_colon_unit __P((char *, int *));
+ #if defined (__MSDOS__)
+ extern char *extract_unit __P((char *, int *, int));
+ #endif
  
  extern void tilde_initialize __P((void));
  extern char *bash_tilde_expand __P((char *));
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/hashcmd.c bash-2.03/hashcmd.c
*** bash203/hashcmd.c	Mon Oct  6 17:22:24 1997
--- bash-2.03/hashcmd.c	Fri Feb 19 17:41:54 1999
***************
*** 151,162 ****
--- 151,173 ----
        /* If the pathname does not start with a `./', add a `./' to it. */
        if (tail[0] != '.' || tail[1] != '/')
  	{
+ #if defined (__MSDOS__)
+           /* for adding extention (dot + 3ext) */
+           dotted_filename = xmalloc (3 + strlen (tail) + 1 + 3);
+ #else
  	  dotted_filename = xmalloc (3 + strlen (tail));
+ #endif
  	  dotted_filename[0] = '.'; dotted_filename[1] = '/';
  	  strcpy (dotted_filename + 2, tail);
  	}
        else
+ #if !defined (__MSDOS__)
  	dotted_filename = savestring (tail);
+ #else
+         dotted_filename = save_filename_string (tail);
+ 
+       dosutil_add_executable_suffix (dotted_filename);
+ #endif
  
        if (executable_file (dotted_filename))
  	return (dotted_filename);
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/input.c bash-2.03/input.c
*** bash203/input.c	Mon Oct 13 12:45:42 1997
--- bash-2.03/input.c	Sun Dec 26 13:02:34 1999
***************
*** 195,201 ****
--- 195,205 ----
  
        /* Now take care of duplicating the file descriptor that bash is
  	 using for input, so we can reinitialize it later. */
+ #if defined (__MSDOS__) && defined (__DJGPP__)
+       nfd = fcntl (fd, F_DUPFD, 20);
+ #else
        nfd = fcntl (fd, F_DUPFD, 10);
+ #endif
        if (nfd == -1)
  	{
  	  if (fcntl (fd, F_GETFD, 0) == 0)
***************
*** 295,304 ****
    if (fd_is_seekable (fd) == 0)
      size = 1;
    else
      size = (size_t)((sb.st_size > MAX_INPUT_BUFFER_SIZE)
  				? MAX_INPUT_BUFFER_SIZE
  				: sb.st_size);
!       
    buffer = (char *)xmalloc (size);
  
    return (make_buffered_stream (fd, buffer, size));
--- 299,317 ----
    if (fd_is_seekable (fd) == 0)
      size = 1;
    else
+ #if defined(__MSDOS__)
+   {
+ #endif
      size = (size_t)((sb.st_size > MAX_INPUT_BUFFER_SIZE)
  				? MAX_INPUT_BUFFER_SIZE
  				: sb.st_size);
! #if defined(__MSDOS__)
!     if (!isatty (fd) && (fd != 0))
!       setmode (fd, O_BINARY);
!     else
!       size = 1;
!   }
! #endif
    buffer = (char *)xmalloc (size);
  
    return (make_buffered_stream (fd, buffer, size));
***************
*** 374,379 ****
--- 387,395 ----
  }
  
  /* Read a buffer full of characters from BP, a buffered stream. */
+ #if defined (__MSDOS__)
+ #define B_USECR 0x100
+ #endif
  static int
  b_fill_buffer (bp)
       BUFFERED_STREAM *bp;
***************
*** 434,443 ****
--- 450,468 ----
    return (0);
  }
  
+ 
  int
  buffered_getchar ()
  {
+ #ifndef __MSDOS__
    return (bufstream_getc (buffers[bash_input.location.buffered_fd]));
+ #else
+   int ch;
+   while ((ch = (bufstream_getc (buffers[bash_input.location.buffered_fd])))
+          == '\r')
+     ;
+   return ch;
+ #endif
  }
  
  int
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/input.h bash-2.03/input.h
*** bash203/input.h	Mon Oct  6 12:41:08 1997
--- bash-2.03/input.h	Fri Feb 19 17:41:54 1999
***************
*** 112,117 ****
--- 112,120 ----
  extern int close_buffered_stream __P((BUFFERED_STREAM *));
  extern int close_buffered_fd __P((int));
  extern int sync_buffered_stream __P((int));
+ #if defined (__MSDOS__)
+ extern int sync_buffered_stream_crlf __P((int));
+ #endif
  extern int buffered_getchar __P((void));
  extern int buffered_ungetchar __P((int));
  extern void with_input_from_buffered_stream __P((int, char *));
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/glob/glob.c bash-2.03/lib/glob/glob.c
*** bash203/lib/glob/glob.c	Thu Sep 17 13:12:34 1998
--- bash-2.03/lib/glob/glob.c	Wed Mar 24 13:45:58 1999
***************
*** 67,73 ****
  #  endif
  #endif /* !HAVE_DIRENT_H */
  
! #if defined (_POSIX_SOURCE)
  /* Posix does not require that the d_ino field be present, and some
     systems do not provide it. */
  #  define REAL_DIR_ENTRY(dp) 1
--- 67,73 ----
  #  endif
  #endif /* !HAVE_DIRENT_H */
  
! #if defined (_POSIX_SOURCE) || defined (__DJGPP__)
  /* Posix does not require that the d_ino field be present, and some
     systems do not provide it. */
  #  define REAL_DIR_ENTRY(dp) 1
***************
*** 117,122 ****
--- 117,130 ----
  extern int extended_glob;
  #endif /* SHELL */
  
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
  /* Global variable which controls whether or not * matches .*.
     Non-zero means don't match .*.  */
  int noglob_dot_filenames = 1;
***************
*** 141,146 ****
--- 149,162 ----
    bopen = 0;
  
    while ((c = *p++) != '\0')
+ #if defined (USE_MULTIBYTE)
+     {
+       if (_ismbblead (c) && *p != '\0')
+ 	{
+ 	  p++;
+ 	  continue;
+ 	}
+ #endif
      switch (c)
        {
        case '?':
***************
*** 166,171 ****
--- 182,190 ----
  	if (*p++ == '\0')
  	  return (0);
        }
+ #if defined (USE_MULTIBYTE)
+     }
+ #endif
  
    return (0);
  }
***************
*** 179,184 ****
--- 198,212 ----
  
    for (i = j = 0; pathname && pathname[i]; )
      {
+ #if defined (USE_MULTIBYTE)
+       if (_ismbblead (pathname[i]) && pathname[i + 1] != '\0')
+ 	{
+ 	  pathname[j++] = pathname[i++];
+ 	  pathname[j++] = pathname[i++];
+ 	  continue;
+ 	}
+ #endif
+ 
        if (pathname[i] == '\\')
  	i++;
  
***************
*** 211,218 ****
--- 239,258 ----
  {
    struct stat finfo;
  
+ #if defined (__MSDOS__)
+   char *fixp;
+ 
+   fixp = dosutil_expand_path (strdup (dir));
+   if (stat (fixp, &finfo) < 0)
+     {
+       free (fixp);
+       return (-1);
+     }
+   free (fixp);
+ #else
    if (stat (dir, &finfo) < 0)
      return (-1);
+ #endif
  
    if (S_ISDIR (finfo.st_mode) == 0)
      return (-1);
***************
*** 247,252 ****
--- 287,296 ----
        char *name;
      };
  
+ #if defined (__MSDOS__)
+   char *fixp;
+   int use_lfn = _USE_LFN;
+ #endif
    DIR *d;
    register struct dirent *dp;
    struct globval *lastlink;
***************
*** 338,344 ****
--- 382,394 ----
  	return ((char **) &glob_error_return);
  #endif
  
+ #if defined (__MSDOS__)
+       fixp = dosutil_expand_path (strdup (dir));
+       d = opendir (fixp);
+       free (fixp);
+ #else
        d = opendir (dir);
+ #endif
        if (d == NULL)
  	return ((char **) &glob_error_return);
  
***************
*** 347,352 ****
--- 397,422 ----
        flags = (noglob_dot_filenames ? FNM_PERIOD : 0) | FNM_PATHNAME;
  
  #ifdef FNM_CASEFOLD
+ #if defined (__DJGPP__)
+       /* DJGPP's globbing does not ignore case
+          when in an LFN environment and either FNCASE=Y
+          or an uppercase letter is in the pattern. */
+ 
+       glob_ignore_case = !(use_lfn && (_preserve_fncase() != 0));
+       if (glob_ignore_case && use_lfn)
+         {
+           char *cur_pat = pat;
+           char ch;
+           while ((ch = *cur_pat++))
+             {
+               if ((ch >= 'A') && (ch <= 'Z'))
+                 {
+                   glob_ignore_case = 0;
+                   break;
+                 }
+             }
+         }
+ #endif
        if (glob_ignore_case)
  	flags |= FNM_CASEFOLD;
  #endif
***************
*** 362,367 ****
--- 432,440 ----
  	 Chain those structs together; lastlink is the front of the chain.  */
        while (1)
  	{
+ #if defined (__DJGPP__)
+           char short_name[13];
+ #endif
  #if defined (SHELL)
  	  /* Make globbing interruptible in the shell. */
  	  if (interrupt_state)
***************
*** 394,399 ****
--- 467,494 ----
  		(pat[0] != '\\' || pat[1] != '.'))
  	    continue;
  
+ #if defined (__DJGPP__)
+          /* Downcase if the short name and long name are equal
+             except for a names which are non-directorie
+             and don't contain periods. This is to keep Unix style
+             files from being downcased. */
+ 
+          if (glob_ignore_case
+              && (strcmp(dp->d_name, _lfn_gen_short_fname (dp->d_name, short_name)) == 0)
+ /*             && !((use_lfn && strchr(dp->d_name, '.') == NULL) && glob_testdir(dp->d_name) < 0) */
+              )
+            {
+              /* Downcase when the SFN matches the LFN */
+              int i;
+              char c;
+              for (i = 0; dp->d_name[i]; i++)
+                {
+                  c = dp->d_name[i];
+                  dp->d_name[i] = ((c >= 'A' && c <= 'Z') ? c - 'A' + 'a' : c);
+                }
+            }
+ #endif
+ 
  	  if (fnmatch (pat, dp->d_name, flags) != FNM_NOMATCH)
  	    {
  	      nextlink = (struct globval *) alloca (sizeof (struct globval));
***************
*** 464,470 ****
--- 559,569 ----
    if (l == 0)
      return (array);
  
+ #if defined (__MSDOS__)
+   add_slash = dir[l - 1] != '/' && dir[l - 1] != ':';
+ #else
    add_slash = dir[l - 1] != '/';
+ #endif
  
    i = 0;
    while (array[i] != NULL)
***************
*** 522,527 ****
--- 621,631 ----
  
    /* Find the filename.  */
    filename = strrchr (pathname, '/');
+ #if defined (__MSDOS__)
+   /* take drive name */
+   if (filename == NULL && isalpha (pathname[0]) && pathname[1] == ':')
+     filename = pathname + 1;
+ #endif
    if (filename == NULL)
      {
        filename = pathname;
***************
*** 645,652 ****
--- 749,762 ----
  
        /* Just return what glob_vector () returns appended to the
  	 directory name. */
+ #if defined(__DJGPP__)
+       __opendir_flags = __OPENDIR_PRESERVE_CASE;
+ #endif
        temp_results =
  	glob_vector (filename, (directory_len == 0 ? "." : directory_name));
+ #if defined (__DJGPP__)
+       __opendir_flags = 0;
+ #endif
  
        if (temp_results == NULL || temp_results == (char **)&glob_error_return)
  	return (temp_results);
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/readline/bind.c bash-2.03/lib/readline/bind.c
*** bash203/lib/readline/bind.c	Tue Feb  2 13:26:20 1999
--- bash-2.03/lib/readline/bind.c	Wed Jul  7 19:47:58 1999
***************
*** 677,685 ****
        return ((char *)NULL);
      }
  
!   buffer[file_size] = '\0';
    if (sizep)
!     *sizep = file_size;
    return (buffer);
  }
  
--- 677,685 ----
        return ((char *)NULL);
      }
  
!   buffer[i] = '\0';
    if (sizep)
!     *sizep = i;
    return (buffer);
  }
  
***************
*** 699,704 ****
--- 699,705 ----
       1. the filename used for the previous call
       2. the value of the shell variable `INPUTRC'
       3. ~/.inputrc
+      4. ~/_inputrc (DOS only)
     If the file existed and could be opened and read, 0 is returned,
     otherwise errno is returned. */
  int
***************
*** 718,723 ****
--- 719,730 ----
    if (*filename == 0)
      filename = DEFAULT_INPUTRC;
  
+ #if defined (HAVE_DOS_FILESYS_LIMITATIONS)
+   if (_rl_read_init_file (filename, 0) == 0)
+     return 0;
+   if (strcmp (filename, "~/.inputrc") == 0)
+     filename = "~/_inputrc";
+ #endif
    return (_rl_read_init_file (filename, 0));
  }
  
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/readline/complete.c bash-2.03/lib/readline/complete.c
*** bash203/lib/readline/complete.c	Thu Feb 18 12:35:56 1999
--- bash-2.03/lib/readline/complete.c	Wed Jul 28 10:45:26 1999
***************
*** 71,76 ****
--- 71,84 ----
  /* Some standard library routines. */
  #include "readline.h"
  
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
  extern char *tilde_expand ();
  extern char *rl_copy_text ();
  extern void _rl_abort_internal ();
***************
*** 417,422 ****
--- 425,435 ----
    char *temp;
  
    temp = rl_filename_completion_desired ? strrchr (pathname, '/') : (char *)NULL;
+ #if defined (HAVE_PATHNAME_STYLE_DOS)
+   if (!temp && rl_filename_completion_desired
+       && (pathname[0] && pathname[1] == ':'))
+       temp = pathname + 1;
+ #endif
    return (temp ? ++temp : pathname);
  }
  
***************
*** 560,565 ****
--- 573,586 ----
        /* FOUND_QUOTE is set so we know what kind of quotes we found. */
        for (scan = pass_next = 0; scan < end; scan++)
  	{
+ #if defined (USE_MULTIBYTE)
+ 	  if (_ismbblead (rl_line_buffer[scan]) && scan+1 < end
+ 	      && rl_line_buffer[scan + 1] != '\0')
+ 	    {
+ 	      scan++;
+ 	      continue;
+ 	    }
+ #endif
  	  if (pass_next)
  	    {
  	      pass_next = 0;
***************
*** 609,614 ****
--- 630,641 ----
  	  if (strchr (rl_completer_word_break_characters, scan) == 0)
  	    continue;
  
+ #ifdef HAVE_PATHNAME_STYLE_DOS
+           if (scan == ':' && (rl_completion_entry_function == NULL
+               || rl_completion_entry_function == (Function *)filename_completion_function))
+             continue;
+ #endif
+ 
  	  /* Call the application-specific function to tell us whether
  	     this word break character is quoted and should be skipped. */
  	  if (rl_char_is_quoted_p && found_quote &&
***************
*** 1067,1075 ****
--- 1094,1116 ----
        /* If there is a single match, see if we need to quote it.
           This also checks whether the common prefix of several
  	 matches needs to be quoted. */
+ #if !defined (HAVE_PATHNAME_STYLE_DOS)
        should_quote = rl_filename_quote_characters
  			? (rl_strpbrk (match, rl_filename_quote_characters) != 0)
  			: 0;
+ #else /* HAVE_PATHNAME_STYLE_DOS */
+       {
+         /* To get here, the match must be a filename.
+            Do not allow ':' to be quoted in DOS-style filenames,
+            to avoid confusing people.  */
+         char *token = NULL;
+         should_quote = rl_filename_quote_characters
+                         ? ((token = rl_strpbrk (match, rl_filename_quote_characters)) != 0)
+ 			: 0;
+         if (token && *token == ':')
+           should_quote = 0;
+       }
+ #endif
  
        do_replace = should_quote ? mtype : NO_MATCH;
        /* Quote the replacement, since we found an embedded
***************
*** 1138,1143 ****
--- 1179,1187 ----
    if (rl_filename_completion_desired)
      {
        filename = tilde_expand (text);
+ #if defined (__MSDOS__)
+       filename = dosutil_expand_path (filename);
+ #endif
        if (stat (filename, &finfo) == 0 && S_ISDIR (finfo.st_mode))
  	{
  	  if (_rl_complete_mark_directories && rl_line_buffer[rl_point] != '/')
***************
*** 1407,1415 ****
       char *text;
       int state;
  {
! #if defined (__GO32__) || defined (__WIN32__) || defined (__OPENNT)
    return (char *)NULL;
! #else /* !__GO32__ */
    static char *username = (char *)NULL;
    static struct passwd *entry;
    static int namelen, first_char, first_char_loc;
--- 1451,1459 ----
       char *text;
       int state;
  {
! #if defined (__WIN32__) || defined (__OPENNT)
    return (char *)NULL;
! #else /* !__WIN32__ */
    static char *username = (char *)NULL;
    static struct passwd *entry;
    static int namelen, first_char, first_char_loc;
***************
*** 1452,1458 ****
  
        return (value);
      }
! #endif /* !__GO32__ */
  }
  
  /* Okay, now we write the entry_function for filename completion.  In the
--- 1496,1502 ----
  
        return (value);
      }
! #endif /* !__WIN32__ */
  }
  
  /* Okay, now we write the entry_function for filename completion.  In the
***************
*** 1499,1504 ****
--- 1543,1556 ----
  	  strcpy (filename, ++temp);
  	  *temp = '\0';
  	}
+ #if defined (HAVE_PATHNAME_STYLE_DOS)
+       /* searches from current directory on the drive */
+       else if (dirname[0] && dirname[1] == ':')
+ 	{
+ 	  strcpy (filename, dirname + 2);
+ 	  dirname[2] = '\0';
+ 	}
+ #endif
        else
  	{
  	  dirname[0] = '.';
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/readline/display.c bash-2.03/lib/readline/display.c
*** bash203/lib/readline/display.c	Thu Dec 17 15:36:30 1998
--- bash-2.03/lib/readline/display.c	Sat Jun 12 14:14:08 1999
***************
*** 41,51 ****
  
  #include <stdio.h>
  
- #if defined (__GO32__)
- #  include <go32.h>
- #  include <pc.h>
- #endif /* __GO32__ */
- 
  /* System-specific feature definitions and include files. */
  #include "rldefs.h"
  
--- 41,46 ----
***************
*** 1066,1076 ****
    if (new == 0 || CR_FASTER (new, _rl_last_c_pos) ||
        (_rl_term_autowrap && i == screenwidth))
      {
- #if defined (__MSDOS__)
-       putc ('\r', rl_outstream);
- #else
        tputs (term_cr, 1, _rl_output_character_function);
- #endif /* !__MSDOS__ */
        _rl_last_c_pos = 0;
      }
  
--- 1061,1067 ----
***************
*** 1114,1128 ****
    if (_rl_last_v_pos == to || to > screenheight)
      return;
  
- #if defined (__GO32__)
-   {
-     int row, col;
- 
-     ScreenGetCursor (&row, &col);
-     ScreenSetCursor ((row + to - _rl_last_v_pos), col);
-   }
- #else /* !__GO32__ */
- 
    if ((delta = to - _rl_last_v_pos) > 0)
      {
        for (i = 0; i < delta; i++)
--- 1105,1110 ----
***************
*** 1136,1142 ****
  	for (i = 0; i < -delta; i++)
  	  tputs (term_up, 1, _rl_output_character_function);
      }
- #endif /* !__GO32__ */
    _rl_last_v_pos = to;		/* Now TO is here */
  }
  
--- 1118,1123 ----
***************
*** 1344,1354 ****
  _rl_clear_to_eol (count)
       int count;
  {
- #if !defined (__GO32__)
    if (term_clreol)
      tputs (term_clreol, 1, _rl_output_character_function);
    else if (count)
- #endif /* !__GO32__ */
      space_to_eol (count);
  }
  
--- 1325,1333 ----
***************
*** 1369,1379 ****
  void
  _rl_clear_screen ()
  {
- #if !defined (__GO32__)
    if (term_clrpag)
      tputs (term_clrpag, 1, _rl_output_character_function);
    else
- #endif /* !__GO32__ */
      crlf ();
  }
  
--- 1348,1356 ----
***************
*** 1383,1402 ****
       char *string;
       int count;
  {
- #if defined (__GO32__)
-   int row, col, width;
-   char *row_start;
- 
-   ScreenGetCursor (&row, &col);
-   width = ScreenCols ();
-   row_start = ScreenPrimary + (row * width);
- 
-   memcpy (row_start + col + count, row_start + col, width - col - count);
- 
-   /* Place the text on the screen. */
-   _rl_output_some_chars (string, count);
- #else /* !_GO32 */
- 
    /* If IC is defined, then we do not have to "enter" insert mode. */
    if (term_IC)
      {
--- 1360,1365 ----
***************
*** 1429,1435 ****
        if (term_ei && *term_ei)
  	tputs (term_ei, 1, _rl_output_character_function);
      }
- #endif /* !__GO32__ */
  }
  
  /* Delete COUNT characters from the display line. */
--- 1392,1397 ----
***************
*** 1437,1454 ****
  delete_chars (count)
       int count;
  {
- #if defined (__GO32__)
-   int row, col, width;
-   char *row_start;
- 
-   ScreenGetCursor (&row, &col);
-   width = ScreenCols ();
-   row_start = ScreenPrimary + (row * width);
- 
-   memcpy (row_start + col, row_start + col + count, width - col - count);
-   memset (row_start + width - count, 0, count * 2);
- #else /* !_GO32 */
- 
    if (count > screenwidth)	/* XXX */
      return;
  
--- 1399,1404 ----
***************
*** 1464,1470 ****
  	while (count--)
  	  tputs (term_dc, 1, _rl_output_character_function);
      }
- #endif /* !__GO32__ */
  }
  
  void
--- 1414,1419 ----
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/readline/funmap.c bash-2.03/lib/readline/funmap.c
*** bash203/lib/readline/funmap.c	Thu Dec 31 10:11:50 1998
--- bash-2.03/lib/readline/funmap.c	Sun Jul 11 16:31:20 1999
***************
*** 102,108 ****
    { "non-incremental-reverse-search-history", rl_noninc_reverse_search },
    { "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
    { "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
! #ifdef __CYGWIN32__
    { "paste-from-clipboard", rl_paste_from_clipboard },
  #endif
    { "possible-completions", rl_possible_completions },
--- 102,108 ----
    { "non-incremental-reverse-search-history", rl_noninc_reverse_search },
    { "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
    { "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
! #if defined(__WIN32__) || defined (__DJGPP__)
    { "paste-from-clipboard", rl_paste_from_clipboard },
  #endif
    { "possible-completions", rl_possible_completions },
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/readline/histfile.c bash-2.03/lib/readline/histfile.c
*** bash203/lib/readline/histfile.c	Tue Sep 15 13:01:56 1998
--- bash-2.03/lib/readline/histfile.c	Mon Jul 26 14:01:56 1999
***************
*** 64,69 ****
--- 64,73 ----
  #  define O_BINARY 0
  #endif /* !__EMX__ */
  
+ #if defined (__MSDOS__)
+ #define HAVE_INITIAL_DOT_LIMITATION
+ #endif
+ 
  #include <errno.h>
  #if !defined (errno)
  extern int errno;
***************
*** 138,144 ****
--- 142,160 ----
  
    buffer = (char *)NULL;
    input = history_filename (filename);
+ 
    file = open (input, O_RDONLY|O_BINARY, 0666);
+ #if defined (HAVE_INITIAL_DOT_LIMITATION)
+   if (file < 0)
+     {
+       char *ch = basename (input);
+       if (*ch == '.')
+       {
+         *ch = '_';
+         file = open (input, O_RDONLY|O_BINARY, 0666);
+       }
+     }
+ #endif
  
    if ((file < 0) || (fstat (file, &finfo) == -1))
      goto error_and_exit;
***************
*** 158,164 ****
  #if 0
    if (read (file, buffer, file_size) != file_size)
  #else
!   if (read (file, buffer, file_size) < 0)
  #endif
      {
    error_and_exit:
--- 174,180 ----
  #if 0
    if (read (file, buffer, file_size) != file_size)
  #else
!   if ((file_size=read (file, buffer, file_size)) < 0)
  #endif
      {
    error_and_exit:
***************
*** 173,178 ****
--- 189,217 ----
  
    close (file);
  
+ #if defined (O_TEXT)
+    {
+     /* Systems which distinguish between text and binary files need
+        to strip the CR characters before each Newline, otherwise the
+        parsing functions won't work.  */
+     char *s, *d;
+     size_t removed = 0;
+ 
+     for (s = buffer, d = buffer; s < buffer + file_size; s++)
+       {
+ 	if (removed)
+ 	  *d = *s;
+ 	if (*s != '\r' || s[1] != '\n')
+ 	  d++;
+ 	else
+ 	  removed++;
+       }
+ 
+     file_size -= removed;
+     buffer[file_size] = '\0';
+   }
+ #endif
+ 
    /* Set TO to larger than end of file if negative. */
    if (to < 0)
      to = file_size;
***************
*** 233,238 ****
--- 272,289 ----
    filename = history_filename (fname);
    file = open (filename, O_RDONLY|O_BINARY, 0666);
  
+ #if defined (HAVE_INITIAL_DOT_LIMITATION)
+   if (file < 0)
+     {
+       char *ch = basename (fname);
+       if (*ch == '.')
+         {
+           *ch = '_';
+           file = open (fname, O_RDONLY|O_BINARY, 0666);
+         }
+     }
+ #endif
+ 
    if (file == -1 || fstat (file, &finfo) == -1)
      goto truncate_exit;
  
***************
*** 248,253 ****
--- 299,307 ----
        goto truncate_exit;
      }
  
+ #if defined(O_TEXT)
+   setmode (file, O_TEXT);
+ #endif
    buffer = xmalloc (file_size + 1);
    chars_read = read (file, buffer, file_size);
    close (file);
***************
*** 279,285 ****
       truncate to. */
    if (i && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
      {
!       write (file, buffer + i, file_size - i);
  
  #if defined (__BEOS__)
        /* BeOS ignores O_TRUNC. */
--- 333,342 ----
       truncate to. */
    if (i && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
      {
! #if defined(O_TEXT)
!       setmode (file, O_TEXT);
! #endif
!       write (file, buffer + i, chars_read - i);
  
  #if defined (__BEOS__)
        /* BeOS ignores O_TRUNC. */
***************
*** 312,322 ****
--- 369,396 ----
    mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY;
    output = history_filename (filename);
  
+ #if defined (HAVE_INITIAL_DOT_LIMITATION)
+   if ((file = open (output, mode, 0600)) == -1)
+     {
+       char *ch = basename (output);
+       if (*ch == '.')
+         {
+           *ch = '_';
+           file = open (output, mode, 0666);
+         }
+       if (file < 0)
+         {
+           FREE (output);
+           return (errno);
+         }
+     }
+ #else
    if ((file = open (output, mode, 0600)) == -1)
      {
        FREE (output);
        return (errno);
      }
+ #endif
  
    if (nelements > history_length)
      nelements = history_length;
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/readline/input.c bash-2.03/lib/readline/input.c
*** bash203/lib/readline/input.c	Tue Sep 15 13:03:28 1998
--- bash-2.03/lib/readline/input.c	Sat Jun 12 14:19:40 1999
***************
*** 96,105 ****
  
  extern int _rl_convert_meta_chars_to_ascii;
  
- #if defined (__GO32__)
- #  include <pc.h>
- #endif /* __GO32__ */
- 
  /* Non-null means it is a pointer to a function to run while waiting for
     character input. */
  Function *rl_event_hook = (Function *)NULL;
--- 96,101 ----
***************
*** 176,192 ****
  static void
  rl_gather_tyi ()
  {
- #if defined (__GO32__)
-   char input;
- 
-   if (isatty (0) && kbhit () && ibuffer_space ())
-     {
-       int i;
-       i = (*rl_getc_function) (rl_instream);
-       rl_stuff_char (i);
-     }
- #else /* !__GO32__ */
- 
    int tty;
    register int tem, result;
    int chars_avail;
--- 172,177 ----
***************
*** 255,261 ****
        if (chars_avail)
  	rl_stuff_char (input);
      }
- #endif /* !__GO32__ */
  }
  
  /* Is there input available to be read on the readline input file
--- 240,245 ----
***************
*** 397,407 ****
    int result, flags;
    unsigned char c;
  
- #if defined (__GO32__)
-   if (isatty (0))
-     return (getkey () & 0x7F);
- #endif /* __GO32__ */
- 
    while (1)
      {
        result = read (fileno (stream), &c, sizeof (unsigned char));
--- 381,386 ----
***************
*** 448,459 ****
  	}
  #endif /* _POSIX_VERSION && EAGAIN && O_NONBLOCK */
  
- #if !defined (__GO32__)
        /* If the error that we received was SIGINT, then try again,
  	 this is simply an interrupted system call to read ().
  	 Otherwise, some error ocurred, also signifying EOF. */
        if (errno != EINTR)
  	return (EOF);
- #endif /* !__GO32__ */
      }
  }
--- 427,436 ----
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/readline/kill.c bash-2.03/lib/readline/kill.c
*** bash203/lib/readline/kill.c	Tue Jun 30 17:16:16 1998
--- bash-2.03/lib/readline/kill.c	Sun Jul 11 17:00:00 1999
***************
*** 637,639 ****
--- 637,711 ----
    return (0);
  }
  #endif /* __CYGWIN32__ */
+ 
+ /* A special paste command to allow DJGPP users to paste
+    from the Windows clipboard. */
+ #if defined (__DJGPP__)
+ #include <dpmi.h>
+ #include <sys/farptr.h>
+ #include <go32.h>
+ 
+ int
+ rl_paste_from_clipboard (count, key)
+      int count, key;
+ {
+   char *data, *ptr;
+   int len, index;
+   __dpmi_regs r;
+   unsigned long offset;
+   char ch;
+ 
+   /* Open the Windows clipboard.  */
+   r.x.ax = 0x1701;
+   __dpmi_int (0x2f, &r);
+   if (r.x.ax == 0)
+     return 0;
+ 
+   /* Get the size of the text in the clipboard.  */
+   r.x.ax = 0x1704;
+   r.x.dx = 1; /* Select plain text.  */
+   __dpmi_int (0x2f, &r);
+   len = r.x.ax + 65536 * r.x.dx;
+   if (len == 0)
+     return (0);
+ 
+   /* Get a pointer to the text.  */
+   r.x.ax = 0x1705;
+   r.x.dx = 1;
+   __dpmi_int (0x2f, &r);
+ 
+   offset = r.x.bx + 16 * r.x.es;
+   if (offset == 0)
+     return 0;
+ 
+   _farsetsel(_dos_ds);
+   while ((ch = _farnspeekb(offset++)) != '\0')
+   {
+     if (ch == '\r')
+       break;
+   }
+   len = offset - (r.x.bx + 16 * r.x.es);
+   if (ch == '\r')
+     --len;
+ 
+   ptr = xmalloc (len + 1);
+   offset = r.x.bx + 16 * r.x.es;
+ 
+   index = 0;
+   _farsetsel(_dos_ds);
+   while (index < len)
+   {
+     ch = _farnspeekb(offset++);
+     ptr[index++] = ch;
+   }
+   ptr[len] = '\0';
+ 
+   /* Close the clipboard.  */
+   r.x.ax = 0x1708;
+   __dpmi_int (0x2f, &r);
+ 
+   rl_insert_text (ptr);
+   free (ptr);
+ }
+ #endif /* __DJGPP__ */
+ 
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/readline/readline.c bash-2.03/lib/readline/readline.c
*** bash203/lib/readline/readline.c	Thu Dec 31 10:10:10 1998
--- bash-2.03/lib/readline/readline.c	Wed Jul  7 00:31:40 1999
***************
*** 70,75 ****
--- 70,80 ----
  /* Evaluates its arguments multiple times. */
  #define SWAP(s, e)  do { int t; t = s; s = e; e = t; } while (0)
  
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ 
  /* NOTE: Functions and variables prefixed with `_rl_' are
     pseudo-global: they are global so they can be shared
     between files in the readline library, but are not intended
***************
*** 163,177 ****
  static void start_using_history ();
  static void bind_arrow_keys ();
  
- #if !defined (__GO32__)
  static void readline_default_bindings ();
- #endif /* !__GO32__ */
- 
- #if defined (__GO32__)
- #  include <go32.h>
- #  include <pc.h>
- #  undef HANDLE_SIGNALS
- #endif /* __GO32__ */
  
  extern char *xmalloc (), *xrealloc ();
  
--- 168,174 ----
***************
*** 745,754 ****
    /* Initialize the terminal interface. */
    _rl_init_terminal_io ((char *)NULL);
  
- #if !defined (__GO32__)
    /* Bind tty characters to readline functions. */
    readline_default_bindings ();
- #endif /* !__GO32__ */
  
    /* Initialize the function names. */
    rl_initialize_funmap ();
--- 742,749 ----
***************
*** 1113,1118 ****
--- 1108,1127 ----
        int lend = rl_end;
  #endif
  
+ #if defined (USE_MULTIBYTE)
+       end = rl_point;
+       while (--count >= 0)
+ 	{
+ 	  end += _mbclen (the_line + end);
+ 	  if (end >= lend)
+ 	    {
+ 	      end = lend;
+ 	      ding ();
+ 	      break;
+ 	    }
+ 	}
+       rl_point = end;
+ #else
        if (end > lend)
  	{
  	  rl_point = lend;
***************
*** 1120,1125 ****
--- 1129,1135 ----
  	}
        else
  	rl_point = end;
+ #endif
      }
    return 0;
  }
***************
*** 1133,1138 ****
--- 1143,1162 ----
      rl_forward (-count, key);
    else if (count > 0)
      {
+ #if defined (USE_MULTIBYTE)
+       while (--count >=0)
+ 	{
+ 	  rl_point--;
+ 	  if (_mbsbtype (the_line, rl_point) == _MBC_TRAIL)
+ 	    rl_point--;
+ 	  if (rl_point < 0)
+ 	    {
+ 	      rl_point = 0;
+ 	      ding ();
+ 	      break;
+ 	    }
+ 	}
+ #else
        if (rl_point < count)
  	{
  	  rl_point = 0;
***************
*** 1140,1145 ****
--- 1164,1170 ----
  	}
        else
          rl_point -= count;
+ #endif
      }
    return 0;
  }
***************
*** 1168,1173 ****
--- 1193,1201 ----
       int count, key;
  {
    int c;
+ #if defined (USE_MULTIBYTE)
+   int clen;
+ #endif
  
    if (count < 0)
      {
***************
*** 1182,1187 ****
--- 1210,1251 ----
  
        /* If we are not in a word, move forward until we are in one.
  	 Then, move forward until we hit a non-alphabetic character. */
+ #if defined (USE_MULTIBYTE)
+       /* move backward if need */
+       if (rl_point > 0 && _mbsbtype (the_line, rl_point) == _MBC_TRAIL)
+ 	rl_point--;
+ 
+       c = the_line[rl_point];
+       if (_mbsbtype (the_line, rl_point) == _MBC_SINGLE && alphabetic (c) == 0)
+ 	{
+ 	  while (rl_point < rl_end)
+ 	    {
+ 	      c = the_line[rl_point++];
+ 	      if (_ismbblead (c))
+ 		{
+ 		  rl_point++;
+ 		  break;
+ 		}
+ 	      else if (alphabetic (c))
+ 		break;
+ 	    }
+ 	}
+ 
+       if (rl_point == rl_end)
+ 	return 0;
+ 
+       while (rl_point < rl_end)
+ 	{
+ 	  c = the_line[rl_point++];
+ 	  if (_ismbblead (c))
+ 	    rl_point++;
+ 	  else if (alphabetic (c) == 0)
+ 	    {
+ 	      rl_point--;
+ 	      break;
+ 	    }
+ 	}
+ #else
        c = the_line[rl_point];
        if (alphabetic (c) == 0)
  	{
***************
*** 1200,1205 ****
--- 1264,1270 ----
  	  if (alphabetic (c) == 0)
  	    break;
  	}
+ #endif
        --count;
      }
    return 0;
***************
*** 1211,1216 ****
--- 1276,1284 ----
       int count, key;
  {
    int c;
+ #if defined (USE_MULTIBYTE)
+   int clen;
+ #endif
  
    if (count < 0)
      {
***************
*** 1226,1231 ****
--- 1294,1331 ----
        /* Like rl_forward_word (), except that we look at the characters
  	 just before point. */
  
+ #if defined (USE_MULTIBYTE)
+       /* move forward if need */
+       if (rl_point < rl_end && _mbsbtype (the_line, rl_point) == _MBC_TRAIL)
+ 	rl_point++;
+ 
+       c = the_line[rl_point - 1];
+       if (_mbsbtype (the_line, rl_point - 1) == _MBC_SINGLE && alphabetic (c) == 0)
+ 	{
+ 	  while (rl_point)
+ 	    {
+ 	      c = the_line[--rl_point];
+ 	      if (rl_point > 0 && _mbsbtype (the_line, rl_point) == _MBC_TRAIL)
+ 		rl_point--;
+ 	      clen = _mbclen (the_line + rl_point);
+ 	      if ((clen == 1 && alphabetic (c)) || clen == 2)
+ 		break;
+ 	    }
+ 	}
+ 
+       while (rl_point)
+ 	{
+ 	  c = the_line[--rl_point];
+ 	  if (_mbsbtype (the_line, rl_point) == _MBC_TRAIL)
+ 	    rl_point--;
+ 	  clen = _mbclen (the_line + rl_point);
+ 	  if (clen == 1 && alphabetic (c) == 0)
+ 	    {
+ 	      rl_point++;
+ 	      break;
+ 	    }
+ 	}
+ #else
        c = the_line[rl_point - 1];
        if (alphabetic (c) == 0)
  	{
***************
*** 1245,1250 ****
--- 1345,1351 ----
  	  else
  	    --rl_point;
  	}
+ #endif
        --count;
      }
    return 0;
***************
*** 1272,1289 ****
    _rl_move_vert (curr_line);
    _rl_move_cursor_relative (0, the_line);   /* XXX is this right */
  
- #if defined (__GO32__)
-   {
-     int row, col, width, row_start;
- 
-     ScreenGetCursor (&row, &col);
-     width = ScreenCols ();
-     row_start = ScreenPrimary + (row * width);
-     memset (row_start + col, 0, (width - col) * 2);
-   }
- #else /* !__GO32__ */
    _rl_clear_to_eol (0);		/* arg of 0 means to not use spaces */
- #endif /* !__GO32__ */
  
    rl_forced_update_display ();
    rl_display_fixed = 1;
--- 1373,1379 ----
***************
*** 1497,1503 ****
--- 1587,1606 ----
    else
      {
        int c = the_line[--rl_point];
+ #if defined (USE_MULTIBYTE)
+       {
+ 	/* for DBCS */
+ 	int len = 1;
+ 	if (rl_point > 0 && _mbsbtype (the_line, rl_point) == _MBC_TRAIL)
+ 	  {
+ 	    len++;
+ 	    c = the_line[--rl_point];
+ 	  }
+ 	rl_delete_text (rl_point, rl_point + len);
+       }
+ #else
        rl_delete_text (rl_point, rl_point + 1);
+ #endif
  
        if (rl_point == rl_end && isprint (c) && _rl_last_c_pos)
  	{
***************
*** 1533,1539 ****
        return 0;
      }
    else
!     return (rl_delete_text (rl_point, rl_point + 1));
  }
  
  /* Delete the character under the cursor, unless the insertion
--- 1636,1652 ----
        return 0;
      }
    else
! #if defined (USE_MULTIBYTE)
!     {
!       /* for DBCS */
!       int len = _mbclen (the_line + rl_point);
!       if (len < 0)
! 	len = 1;
!       return (rl_delete_text (rl_point, rl_point + len));
!     }
! #else
!   return (rl_delete_text (rl_point, rl_point + 1));
! #endif
  }
  
  /* Delete the character under the cursor, unless the insertion
***************
*** 1666,1671 ****
--- 1779,1791 ----
    for (inword = 0; start < end; start++)
      {
        c = the_line[start];
+ #if defined (USE_MULTIBYTE)
+       if (_ismbblead (c) && start+1 < end)
+ 	{
+ 	  start++;
+ 	  continue;
+ 	}
+ #endif
        switch (op)
  	{
  	case UpCase:
***************
*** 1762,1768 ****
--- 1882,1893 ----
  rl_transpose_chars (count, key)
       int count, key;
  {
+ #if defined (USE_MULTIBYTE)
+   /* for DBCS */
+   char dummy[2 + 1];
+ #else
    char dummy[2];
+ #endif
  
    if (!count)
      return 0;
***************
*** 1778,1787 ****
--- 1903,1950 ----
    if (rl_point == rl_end)
      {
        --rl_point;
+ #if defined (USE_MULTIBYTE)
+       if (rl_point > 0 && _mbsbtype (the_line, rl_point) == _MBC_TRAIL)
+ 	rl_point--;
+ #endif
        count = 1;
      }
    rl_point--;
  
+ #if defined (USE_MULTIBYTE)
+   if (rl_point > 0 && _mbsbtype (the_line, rl_point) == _MBC_TRAIL)
+     rl_point--;
+   dummy[0] = dummy[1] = dummy[2] = '\0';
+   _mbccpy (dummy, the_line + rl_point);
+   rl_delete_text (rl_point, rl_point + _mbclen (the_line + rl_point));
+   if (count >= 0)
+     {
+       while (--count >= 0)
+ 	{
+ 	  rl_point += _mbclen (the_line + rl_point);
+ 	  if (rl_point >= rl_end)
+ 	    {
+ 	      rl_point = rl_end;
+ 	      break;
+ 	    }
+ 	}
+     }
+   else
+     {
+       while (++count <= 0)
+ 	{
+ 	  rl_point--;
+ 	  if (rl_point > 0 && _mbsbtype (the_line, rl_point) == _MBC_TRAIL)
+ 	    rl_point--;
+ 	  if (rl_point <= 0)
+ 	    {
+ 	      rl_point = 0;
+ 	      break;
+ 	    }
+ 	}
+     }
+   rl_insert_text (dummy);
+ #else
    dummy[0] = the_line[rl_point];
    dummy[1] = '\0';
  
***************
*** 1790,1795 ****
--- 1953,1959 ----
    rl_point += count;
    _rl_fix_point (0);
    rl_insert_text (dummy);
+ #endif
  
    rl_end_undo_group ();
    return 0;
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/readline/readline.h bash-2.03/lib/readline/readline.h
*** bash203/lib/readline/readline.h	Thu Dec 31 10:10:14 1998
--- bash-2.03/lib/readline/readline.h	Sun Jul 11 16:30:44 1999
***************
*** 155,162 ****
  extern int rl_yank_pop __P((int, int));
  extern int rl_yank_nth_arg __P((int, int));
  extern int rl_yank_last_arg __P((int, int));
! /* Not available unless __CYGWIN32__ is defined. */
! #ifdef __CYGWIN32__
  extern int rl_paste_from_clipboard __P((int, int));
  #endif
  
--- 155,162 ----
  extern int rl_yank_pop __P((int, int));
  extern int rl_yank_nth_arg __P((int, int));
  extern int rl_yank_last_arg __P((int, int));
! /* Not available unless __WIN32__ or __DJGPP__ is defined. */
! #if defined (__WIN32__) || defined (__DJGPP__)
  extern int rl_paste_from_clipboard __P((int, int));
  #endif
  
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/readline/rltty.c bash-2.03/lib/readline/rltty.c
*** bash203/lib/readline/rltty.c	Wed May 13 17:55:40 1998
--- bash-2.03/lib/readline/rltty.c	Sat Jun 12 14:28:02 1999
***************
*** 55,65 ****
  
  extern void _rl_control_keypad ();
  
- #if defined (__GO32__)
- #  include <pc.h>
- #  undef HANDLE_SIGNALS
- #endif /* __GO32__ */
- 
  /* Indirect functions to allow apps control over terminal management. */
  extern void rl_prep_terminal (), rl_deprep_terminal ();
  
--- 55,60 ----
***************
*** 258,264 ****
       int meta_flag;
       TIOTYPE otio, *tiop;
  {
- #if !defined (__GO32__)
    readline_echoing_p = (otio.sgttyb.sg_flags & ECHO);
  
    /* Copy the original settings to the structure we're going to use for
--- 253,258 ----
***************
*** 324,330 ****
    tiop->ltchars.t_dsuspc = -1;	/* C-y */
    tiop->ltchars.t_lnextc = -1;	/* C-v */
  #endif /* TIOCGLTC */
- #endif /* !__GO32__ */
  }
  
  #else  /* !defined (NEW_TTY_DRIVER) */
--- 318,323 ----
***************
*** 388,394 ****
--- 381,389 ----
  {
    int ioctl_ret;
  
+ #if defined (TIOCGWINSZ)
    set_winsize (tty);
+ #endif
  
    while (1)
      {
***************
*** 520,526 ****
  rl_prep_terminal (meta_flag)
       int meta_flag;
  {
- #if !defined (__GO32__)
    int tty;
    TIOTYPE tio;
  
--- 515,520 ----
***************
*** 555,568 ****
    terminal_prepped = 1;
  
    release_sigint ();
- #endif /* !__GO32__ */
  }
  
  /* Restore the terminal's normal settings and modes. */
  void
  rl_deprep_terminal ()
  {
- #if !defined (__GO32__)
    int tty;
  
    if (!terminal_prepped)
--- 549,560 ----
***************
*** 587,593 ****
    terminal_prepped = 0;
  
    release_sigint ();
- #endif /* !__GO32__ */
  }
  
  /* **************************************************************** */
--- 579,584 ----
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/readline/signals.c bash-2.03/lib/readline/signals.c
*** bash203/lib/readline/signals.c	Thu May 14 12:56:26 1998
--- bash-2.03/lib/readline/signals.c	Sat Jun 12 14:30:56 1999
***************
*** 40,49 ****
  #  include <sys/ioctl.h>
  #endif /* GWINSZ_IN_SYS_IOCTL */
  
- #if defined (__GO32__)
- #  undef HANDLE_SIGNALS
- #endif /* __GO32__ */
- 
  #if defined (HANDLE_SIGNALS)
  /* Some standard library routines. */
  #include "readline.h"
--- 40,45 ----
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/readline/terminal.c bash-2.03/lib/readline/terminal.c
*** bash203/lib/readline/terminal.c	Thu May 14 10:54:16 1998
--- bash-2.03/lib/readline/terminal.c	Sat Jun 12 14:33:24 1999
***************
*** 298,325 ****
  _rl_init_terminal_io (terminal_name)
       char *terminal_name;
  {
- #if defined (__GO32__)
-   screenwidth = ScreenCols ();
-   screenheight = ScreenRows ();
-   screenchars = screenwidth * screenheight;
-   term_cr = "\r";
-   term_im = term_ei = term_ic = term_IC = (char *)NULL;
-   term_up = term_dc = term_DC = visible_bell = (char *)NULL;
- 
-   /* Does the __GO32__ have a meta key?  I don't know. */
-   term_has_meta = 0;
-   term_mm = term_mo = (char *)NULL;
- 
-   /* It probably has arrow keys, but I don't know what they are. */
-   term_ku = term_kd = term_kr = term_kl = (char *)NULL;
- 
- #if defined (HACK_TERMCAP_MOTION)
-   term_forward_char = (char *)NULL;
- #endif /* HACK_TERMCAP_MOTION */
-   terminal_can_insert = _rl_term_autowrap = 0;
-   return;
- #else /* !__GO32__ */
- 
    char *term, *buffer;
    int tty;
    Keymap xkeymap;
--- 298,303 ----
***************
*** 413,419 ****
  
    _rl_keymap = xkeymap;
  
- #endif /* !__GO32__ */
    return 0;
  }
  
--- 391,396 ----
***************
*** 475,486 ****
  {
    register int i;
  
- #if !defined (__GO32__)
    if (term_backspace)
      for (i = 0; i < count; i++)
        tputs (term_backspace, 1, _rl_output_character_function);
    else
- #endif /* !__GO32__ */
      for (i = 0; i < count; i++)
        putc ('\b', _rl_out_stream);
    return 0;
--- 452,461 ----
***************
*** 504,510 ****
  {
    if (readline_echoing_p)
      {
- #if !defined (__GO32__)
        switch (_rl_bell_preference)
          {
  	case NO_BELL:
--- 479,484 ----
***************
*** 522,531 ****
  	  fflush (stderr);
  	  break;
          }
- #else /* __GO32__ */
-       fprintf (stderr, "\007");
-       fflush (stderr);
- #endif /* __GO32__ */
        return (0);
      }
    return (-1);
--- 496,501 ----
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/readline/tilde.c bash-2.03/lib/readline/tilde.c
*** bash203/lib/readline/tilde.c	Thu May 14 15:47:28 1998
--- bash-2.03/lib/readline/tilde.c	Tue Jun 29 19:52:32 1999
***************
*** 67,72 ****
--- 67,80 ----
  #  endif /* !__STDC__ */
  #endif /* !NULL */
  
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ #if defined (__MSDOS__)
+ #include <dosutil.h>
+ #endif
+ 
  #if defined (TEST) || defined (STATIC_MALLOC)
  static char *xmalloc (), *xrealloc ();
  #else
***************
*** 161,167 ****
--- 169,186 ----
  
    for (i = 0; i < string_len; i++)
      {
+ #if defined (USE_MULTIBYTE)
+       if (_ismbblead (string[i]) && i+1 < string_len)
+ 	{
+ 	  i++;
+ 	  continue;
+ 	}
+ #endif
+ #if defined (HAVE_PATHNAME_STYLE_DOS)
+       if (string[i] == '/' || string[i] == '\\' /* || !string[i] */)
+ #else
        if (string[i] == '/' /* || !string[i] */)
+ #endif
  	break;
  
        for (j = 0; suffixes && suffixes[j]; j++)
***************
*** 250,257 ****
--- 269,292 ----
    int i;
  
    ret = xmalloc (strlen (fname));
+ #if defined (HAVE_PATHNAME_STYLE_DOS)
+   for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++)
+ #else
    for (i = 1; fname[i] && fname[i] != '/'; i++)
+ #endif
+ #if defined (USE_MULTIBYTE)
+     {
+       ret[i - 1] = fname[i];
+       if (_ismbblead (fname[i]) && fname[i+1])
+ 	{
+ 	  i++;
+ 	  ret[i - 1] = fname[i];
+ 	  continue;
+ 	}
+     }
+ #else
      ret[i - 1] = fname[i];
+ #endif
    ret[i - 1] = '\0';
    if (lenp)
      *lenp = i;
***************
*** 274,279 ****
--- 309,317 ----
    if (prefix && *prefix)
      strcpy (ret, prefix);
    strcpy (ret + plen, suffix + suffind);
+ #if defined (__MSDOS__)
+   ret = dosutil_expand_path (ret);
+ #endif
    return ret;
  }
  
***************
*** 297,303 ****
--- 335,345 ----
    /* A leading `~/' or a bare `~' is *always* translated to the value of
       $HOME or the home directory of the current user, regardless of any
       preexpansion hook. */
+ #if defined (HAVE_PATHNAME_STYLE_DOS)
+   if (filename[1] == '\0' || filename[1] == '/' || filename[1] == '\\')
+ #else
    if (filename[1] == '\0' || filename[1] == '/')
+ #endif
      {
        /* Prefix $HOME to the rest of the string. */
        expansion = get_env_value ("HOME");
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/termcap/termcap.c bash-2.03/lib/termcap/termcap.c
*** bash203/lib/termcap/termcap.c	Thu Jul 17 09:55:30 1997
--- bash-2.03/lib/termcap/termcap.c	Tue Mar 30 13:19:00 1999
***************
*** 52,57 ****
--- 52,68 ----
  
  #endif /* not HAVE_CONFIG_H */
  
+ #if defined (HAVE_STDLIB_H)
+ #include <stdlib.h>
+ #endif
+ #if defined (HAVE_STRING_H)
+ #include <string.h>
+ #endif
+ #if defined (__MSDOS__)
+ #include <limits.h>
+ extern char *dosutil_expand_path (char *path);
+ #endif
+ 
  #ifndef NULL
  #define NULL (char *) 0
  #endif
***************
*** 393,399 ****
  valid_filename_p (fn)
       char *fn;
  {
!   return *fn == '/' || fn[1] == ':';
  }
  #else
  #define valid_filename_p(fn) (*(fn) == '/')
--- 404,410 ----
  valid_filename_p (fn)
       char *fn;
  {
!   return *fn == '/' || *fn == '\\'|| (*fn && fn[1] == ':');
  }
  #else
  #define valid_filename_p(fn) (*(fn) == '/')
***************
*** 456,463 ****
--- 467,490 ----
    if (termcap_name && (*termcap_name == '\\'
  		       || *termcap_name == '/'
  		       || termcap_name[1] == ':'))
+ #if defined (__MSDOS__)
+     {
+       static char buffer[PATH_MAX + 1];
+       char *p = xmalloc (strlen (termcap_name) + 1);
+       strcpy (p, termcap_name);
+       p = dosutil_expand_path (p);
+       if (strlen (p) < PATH_MAX)
+ 	{
+ 	  strcpy (buffer, p);
+ 	  termcap_name = buffer;
+ 	}
+       if (p != NULL)
+ 	free(p);
+     }
+ #else
      dostounix_filename(termcap_name);
  #endif
+ #endif /* __MSDOS__ */
  
    filep = termcap_name && valid_filename_p (termcap_name);
  
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/termcap/tparam.c bash-2.03/lib/termcap/tparam.c
*** bash203/lib/termcap/tparam.c	Wed Jul 26 14:22:50 1995
--- bash-2.03/lib/termcap/tparam.c	Fri Feb 19 17:42:02 1999
***************
*** 50,56 ****
  xmalloc (size)
       unsigned size;
  {
!   register char *tem = malloc (size);
  
    if (!tem)
      memory_out ();
--- 50,56 ----
  xmalloc (size)
       unsigned size;
  {
!   register char *tem = (char *)malloc (size);
  
    if (!tem)
      memory_out ();
***************
*** 62,68 ****
       char *ptr;
       unsigned size;
  {
!   register char *tem = realloc (ptr, size);
  
    if (!tem)
      memory_out ();
--- 62,68 ----
       char *ptr;
       unsigned size;
  {
!   register char *tem = (char *)realloc (ptr, size);
  
    if (!tem)
      memory_out ();
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/lib/tilde/tilde.c bash-2.03/lib/tilde/tilde.c
*** bash203/lib/tilde/tilde.c	Thu May 14 15:47:28 1998
--- bash-2.03/lib/tilde/tilde.c	Fri Feb 19 18:25:28 1999
***************
*** 47,52 ****
--- 47,60 ----
  
  #include "tilde.h"
  
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ #if defined (__MSDOS__)
+ #include <dosutil.h>
+ #endif
+ 
  #if !defined (HAVE_GETPW_DECLS)
  extern struct passwd *getpwuid (), *getpwnam ();
  #endif /* !HAVE_GETPW_DECLS */
***************
*** 161,167 ****
--- 169,186 ----
  
    for (i = 0; i < string_len; i++)
      {
+ #if defined (USE_MULTIBYTE)
+       if (_ismbblead (string[i]) && i+1 < string_len)
+ 	{
+ 	  i++;
+ 	  continue;
+ 	}
+ #endif
+ #if defined (__MSDOS__)
+       if (string[i] == '/' || string[i] == '\\' /* || !string[i] */)
+ #else
        if (string[i] == '/' /* || !string[i] */)
+ #endif
  	break;
  
        for (j = 0; suffixes && suffixes[j]; j++)
***************
*** 250,257 ****
--- 269,292 ----
    int i;
  
    ret = xmalloc (strlen (fname));
+ #if defined (__MSDOS__)
+   for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++)
+ #else
    for (i = 1; fname[i] && fname[i] != '/'; i++)
+ #endif
+ #if defined (USE_MULTIBYTE)
+     {
      ret[i - 1] = fname[i];
+       if (_ismbblead (fname[i]) && fname[i+1])
+ 	{
+ 	  i++;
+ 	  ret[i - 1] = fname[i];
+ 	  continue;
+ 	}
+     }
+ #else
+     ret[i - 1] = fname[i];
+ #endif
    ret[i - 1] = '\0';
    if (lenp)
      *lenp = i;
***************
*** 274,279 ****
--- 309,317 ----
    if (prefix && *prefix)
      strcpy (ret, prefix);
    strcpy (ret + plen, suffix + suffind);
+ #if defined (__MSDOS__)
+   ret = dosutil_expand_path (ret);
+ #endif
    return ret;
  }
  
***************
*** 297,303 ****
--- 335,345 ----
    /* A leading `~/' or a bare `~' is *always* translated to the value of
       $HOME or the home directory of the current user, regardless of any
       preexpansion hook. */
+ #if defined (__MSDOS__)
+   if (filename[1] == '\0' || filename[1] == '/' || filename[1] == '\\')
+ #else
    if (filename[1] == '\0' || filename[1] == '/')
+ #endif
      {
        /* Prefix $HOME to the rest of the string. */
        expansion = get_env_value ("HOME");
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/mailcheck.c bash-2.03/mailcheck.c
*** bash203/mailcheck.c	Wed Feb  4 15:30:32 1998
--- bash-2.03/mailcheck.c	Fri Feb 19 17:42:02 1999
***************
*** 37,42 ****
--- 37,51 ----
  #include "mailcheck.h"
  #include <tilde/tilde.h>
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ 
  #ifndef NOW
  #define NOW ((time_t)time ((time_t *)0))
  #endif
***************
*** 277,283 ****
--- 286,297 ----
  	  pass_next = 0;
  	  continue;
  	}
+ #if defined (USE_MULTIBYTE)
+       if (*s == '\\' && ((int) (s-str) == 0
+ 			 || _mbsbtype (str, (int) (s-str)) != _MBC_TRAIL))
+ #else
        if (*s == '\\')
+ #endif
  	{
  	  pass_next++;
  	  continue;
***************
*** 328,334 ****
--- 342,352 ----
        return;
      }
  
+ #if defined (__MSDOS__)
+   while (mailfile = extract_unit (mailpaths, &i, dosutil_path_separator))
+ #else
    while (mailfile = extract_colon_unit (mailpaths, &i))
+ #endif
      {
        mp = parse_mailpath_spec (mailfile);
        if (mp && *mp)
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/make_cmd.c bash-2.03/make_cmd.c
*** bash203/make_cmd.c	Tue Jan 12 12:45:36 1999
--- bash-2.03/make_cmd.c	Fri Feb 19 17:42:02 1999
***************
*** 46,51 ****
--- 46,56 ----
  #include "jobs.h"
  #endif
  
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ 
  extern int line_number, current_command_line_count;
  extern int disallow_filename_globbing;
  
***************
*** 76,81 ****
--- 81,94 ----
    register char *s;
  
    for (s = string; *s; s++)
+ #if defined (USE_MULTIBYTE)
+     {
+       if (_ismbblead (*s) && s[1] != '\0')
+ 	{
+ 	  s++;
+ 	  continue;
+ 	}
+ #endif
      switch (*s)
        {
  	case '$':
***************
*** 89,94 ****
--- 102,110 ----
  	  w->flags |= W_QUOTED;
  	  break;
        }
+ #if defined (USE_MULTIBYTE)
+     }
+ #endif
    return (w);
  }
  
***************
*** 539,557 ****
--- 555,585 ----
      case r_output_force:		/* >| foo */
      case r_err_and_out:			/* command &>filename */
        temp->flags = O_TRUNC | O_WRONLY | O_CREAT;
+ #if defined (__MSDOS__)
+       temp->flags |= O_TEXT;
+ #endif
        break;
  
      case r_appending_to:		/* >>foo */
        temp->flags = O_APPEND | O_WRONLY | O_CREAT;
+ #if defined (__MSDOS__)
+       temp->flags |= O_TEXT;
+ #endif
        break;
  
      case r_input_direction:		/* <foo */
      case r_inputa_direction:		/* foo & makes this. */
        temp->flags = O_RDONLY;
+ #if defined (__MSDOS__)
+       temp->flags |= O_TEXT;
+ #endif
        break;
  
      case r_input_output:		/* <>foo */
        temp->flags = O_RDWR | O_CREAT;
+ #if defined (__MSDOS__)
+       temp->flags |= O_TEXT;
+ #endif
        break;
  
      case r_deblank_reading_until: 	/* <<-foo */
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/manifest bash-2.03/manifest
*** bash203/manifest	Thu Feb 18 12:46:44 1999
--- bash-2.03/manifest	Wed Jan 12 11:10:46 2000
***************
*** 49,55 ****
  Makefile.in	f
  config-top.h	f
  config-bot.h	f
! config.h.in	f
  aclocal.m4	f
  array.c		f
  eval.c		f
--- 49,55 ----
  Makefile.in	f
  config-top.h	f
  config-bot.h	f
! config.h-in	f
  aclocal.m4	f
  array.c		f
  eval.c		f
***************
*** 129,136 ****
  bashtypes.h	f
  mailcheck.h	f
  pathnames.h	f
! y.tab.c		f
! y.tab.h		f
  posixdir.h	f
  posixjmp.h	f
  posixstat.h	f
--- 129,136 ----
  bashtypes.h	f
  mailcheck.h	f
  pathnames.h	f
! y_tab.c		f
! y_tab.h		f
  posixdir.h	f
  posixjmp.h	f
  posixstat.h	f
***************
*** 313,322 ****
  lib/termcap/tparam.c	f
  lib/termcap/version.c	f
  lib/termcap/grot/termcap.info	f
- lib/termcap/grot/termcap.info-1	f
- lib/termcap/grot/termcap.info-2	f
- lib/termcap/grot/termcap.info-3	f
- lib/termcap/grot/termcap.info-4	f
  lib/termcap/grot/NEWS	f
  lib/termcap/grot/INSTALL	f
  lib/termcap/grot/ChangeLog	f
--- 313,318 ----
***************
*** 423,429 ****
  examples/functions/autoload.v2	f
  examples/functions/autoload.v3	f
  examples/functions/basename	f
! examples/functions/basename2	f
  examples/functions/csh-compat	f
  examples/functions/dirfuncs	f
  examples/functions/dirname	f
--- 419,425 ----
  examples/functions/autoload.v2	f
  examples/functions/autoload.v3	f
  examples/functions/basename	f
! examples/functions/basenam2	f
  examples/functions/csh-compat	f
  examples/functions/dirfuncs	f
  examples/functions/dirname	f
***************
*** 470,476 ****
  examples/scripts/precedence	f
  examples/scripts/randomcard.bash	f
  examples/scripts/scrollbar	f
! examples/scripts/scrollbar2	f
  examples/scripts/showperm.bash	f
  examples/scripts/shprompt	f
  examples/scripts/spin.bash	f
--- 466,472 ----
  examples/scripts/precedence	f
  examples/scripts/randomcard.bash	f
  examples/scripts/scrollbar	f
! examples/scripts/scrollb2	f
  examples/scripts/showperm.bash	f
  examples/scripts/shprompt	f
  examples/scripts/spin.bash	f
***************
*** 599,605 ****
  tests/run-minimal	f
  tests/run-arith		f
  tests/run-array		f
! tests/run-array2	f
  tests/run-braces	f
  tests/run-builtins	f
  tests/run-cond		f
--- 595,601 ----
  tests/run-minimal	f
  tests/run-arith		f
  tests/run-array		f
! tests/run-arr2	f
  tests/run-braces	f
  tests/run-builtins	f
  tests/run-cond		f
***************
*** 614,620 ****
  tests/run-getopts	f
  tests/run-glob-test	f
  tests/run-heredoc	f
! tests/run-histexpand	f
  tests/run-history	f
  tests/run-ifs-tests	f
  tests/run-input-test	f
--- 610,616 ----
  tests/run-getopts	f
  tests/run-glob-test	f
  tests/run-heredoc	f
! tests/run-hisxpand	f
  tests/run-history	f
  tests/run-ifs-tests	f
  tests/run-input-test	f
***************
*** 623,629 ****
  tests/run-new-exp	f
  tests/run-nquote	f
  tests/run-posix2	f
! tests/run-posixpat	f
  tests/run-precedence	f
  tests/run-printf	f
  tests/run-quote		f
--- 619,625 ----
  tests/run-new-exp	f
  tests/run-nquote	f
  tests/run-posix2	f
! tests/run-psxpat	f
  tests/run-precedence	f
  tests/run-printf	f
  tests/run-quote		f
***************
*** 695,701 ****
  examples/scripts.noah/PERMISSION	f
  examples/scripts.noah/README	f
  examples/scripts.noah/aref.bash	f
! examples/scripts.noah/bash.sub.bash	f
  examples/scripts.noah/bash_version.bash	f
  examples/scripts.noah/meta.bash	f
  examples/scripts.noah/mktmp.bash	f
--- 691,697 ----
  examples/scripts.noah/PERMISSION	f
  examples/scripts.noah/README	f
  examples/scripts.noah/aref.bash	f
! examples/scripts.noah/bash_sub.bash	f
  examples/scripts.noah/bash_version.bash	f
  examples/scripts.noah/meta.bash	f
  examples/scripts.noah/mktmp.bash	f
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/nojobs.c bash-2.03/nojobs.c
*** bash203/nojobs.c	Tue Sep 15 12:42:00 1998
--- bash-2.03/nojobs.c	Fri Feb 19 17:42:04 1999
***************
*** 86,91 ****
--- 86,95 ----
  /* Return the fd from which we are actually getting input. */
  #define input_tty() (shell_tty != -1) ? shell_tty : fileno (stderr)
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
  #if !defined (errno)
  extern int errno;
  #endif /* !errno */
***************
*** 364,370 ****
--- 368,378 ----
    retry_fork:
  #endif /* HAVE_WAITPID */
  
+ #if defined (__MSDOS__)
+   if ((pid = dosutil_make_child_pid ()) < 0)
+ #else
    if ((pid = fork ()) < 0)
+ #endif
      {
  #if defined (HAVE_WAITPID)
        /* Posix systems with a non-blocking waitpid () system call available
***************
*** 410,415 ****
--- 418,426 ----
  
        add_pid (pid);
      }
+ #if defined (__MSDOS__)
+   dosutil_current_pid = pid;
+ #endif
    return (pid);
  }
  
***************
*** 545,550 ****
--- 556,572 ----
    if (!interactive_shell)
      old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
  
+ #if defined (__MSDOS__)
+   {
+     status = dosutil_wait_status;
+     if ((status & 0x0000ff00) == 0x0000ff00)
+       status &= 0x000000ff;
+     errno = 0;
+     got_pid = pid;
+ 
+     last_made_pid = NO_PID;
+   }
+ #else
    while ((got_pid = WAITPID (-1, &status, 0)) != pid) /* XXX was pid now -1 */
      {
        if (got_pid < 0 && errno == ECHILD)
***************
*** 561,566 ****
--- 583,589 ----
        else if (got_pid > 0)
  	set_pid_status (got_pid, status);
      }
+ #endif /* !__MSDOS__ */
  
    set_pid_status (got_pid, status);
  
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/parse.y bash-2.03/parse.y
*** bash203/parse.y	Thu Feb 18 10:35:56 1999
--- bash-2.03/parse.y	Thu Apr  1 15:15:26 1999
***************
*** 71,76 ****
--- 71,85 ----
  #  include "maxpath.h"
  #endif /* PROMPT_STRING_DECODE */
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ 
  #define RE_READ_TOKEN	-99
  #define NO_EXPANSION	-100
  
***************
*** 1394,1400 ****
--- 1403,1414 ----
  	  line_buffer[indx++] = c;
  	  pass_next = 0;
          }
+ #if defined (USE_MULTIBYTE)
+       else if (c == '\\' && (indx == 0 || _mbsbtype (line_buffer, indx) != _MBC_TRAIL)
+ 	       && remove_quoted_newline)
+ #else
        else if (c == '\\' && remove_quoted_newline)
+ #endif
  	{
  	  peekc = yy_getc ();
  	  if (peekc == '\n')
***************
*** 1670,1676 ****
--- 1684,1698 ----
    if (c)
      shell_input_line_index++;
  
+ #if defined (USE_MULTIBYTE)
+   if (c == '\\' && (shell_input_line_index == 1
+ 		    || (shell_input_line_index > 0
+ 			&& _mbsbtype (shell_input_line,
+ 				      shell_input_line_index-1) != _MBC_TRAIL))
+       && remove_quoted_newline &&
+ #else
    if (c == '\\' && remove_quoted_newline &&
+ #endif
        shell_input_line[shell_input_line_index] == '\n')
      {
  	prompt_again ();
***************
*** 2362,2367 ****
--- 2384,2394 ----
  	}
        else if (ch == close)		/* ending delimiter */
  	count--;
+ #if 1
+       /* handle nested ${...} specially. */
+       else if (open != close && was_dollar && open == '{' && ch == open) /* } */
+         count++;
+ #endif
        else if (((flags & P_FIRSTCLOSE) == 0) && ch == open)		/* nested begin */
  	count++;
  
***************
*** 2711,2716 ****
--- 2738,2751 ----
  	  goto got_character;
  	}
  
+ #if defined (USE_MULTIBYTE)
+ 	if (_ismbblead (character))
+ 	  {
+ 	    pass_next_character = 1;
+ 	    goto got_character;
+ 	  }
+ #endif
+ 
        cd = current_delimiter (dstack);
  
        /* Handle backslashes.  Quote lots of things when not inside of
***************
*** 3310,3315 ****
--- 3345,3353 ----
    int c, n;
    char *temp, octal_string[4];
    time_t the_time;
+ #if defined (USE_MULTIBYTE)
+   int skip_next = 0;
+ #endif
  
    result = xmalloc (result_size = PROMPT_GROWTH);
    result[result_index = 0] = 0;
***************
*** 3317,3322 ****
--- 3355,3373 ----
  
    while (c = *string++)
      {
+ #if defined (USE_MULTIBYTE)
+       if (skip_next)
+ 	{
+ 	  skip_next = 0;
+ 	  goto next_character;
+ 	}
+ 
+       if (_ismbblead (c))
+ 	{
+ 	  skip_next = 1;
+ 	  goto next_character;
+ 	}
+ #endif
        if (posixly_correct && c == '!')
  	{
  	  if (*string == '!')
***************
*** 3450,3456 ****
--- 3501,3511 ----
  
  		if (temp == 0)
  		  {
+ #if defined (__MSDOS__)
+ 		    if (dosutil_getcwd (t_string, sizeof(t_string)) == 0)
+ #else
  		    if (getcwd (t_string, sizeof(t_string)) == 0)
+ #endif
  		      {
  		        t_string[0] = '.';
  			tlen = 1;
***************
*** 3558,3563 ****
--- 3613,3621 ----
  	}
        else
  	{
+ #if defined (USE_MULTIBYTE)
+ next_character:
+ #endif
  	  RESIZE_MALLOCED_BUFFER (result, result_index, 3, result_size, PROMPT_GROWTH);
  	  result[result_index++] = c;
  	  result[result_index] = '\0';
***************
*** 3643,3649 ****
--- 3701,3711 ----
        if (i)
  	token_end = i + 1;
  
+ #if defined (USE_MULTIBYTE)
+       while (i && (_mbsbtype (t, i) == _MBC_TRAIL || (member (t[i], " \n\t;|&") == 0)))
+ #else
        while (i && (member (t[i], " \n\t;|&") == 0))
+ #endif
  	i--;
  
        while (i != token_end && (whitespace (t[i]) || t[i] == '\n'))
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/pathexp.c bash-2.03/pathexp.c
*** bash203/pathexp.c	Thu Feb 18 11:10:34 1999
--- bash-2.03/pathexp.c	Fri Feb 19 17:55:22 1999
***************
*** 41,46 ****
--- 41,50 ----
  #  include <glob/glob.h>
  #endif
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
  /* Control whether * matches .files in globbing. */
  int glob_dot_filenames;
  
***************
*** 54,63 ****
--- 58,83 ----
  {
    register int c;
    int open;
+ #if defined (USE_MULTIBYTE)
+   int skip_next = 0;
+ #endif
  
    open = 0;
    while (c = *string++)
      {
+ #if defined (USE_MULTIBYTE)
+       if (skip_next)
+ 	{
+ 	  skip_next = 0;
+ 	  continue;
+ 	}
+ 
+       if (_ismbblead (c))
+ 	{
+ 	  skip_next = 1;
+ 	  continue;
+ 	}
+ #endif
        switch (c)
  	{
  	case '?':
***************
*** 374,380 ****
--- 394,404 ----
  
    numitems = maxitems = ptr = 0;
  
+ #if defined (__MSDOS__)
+   while (colon_bit = extract_unit (this_ignoreval, &ptr, dosutil_path_separator))
+ #else
    while (colon_bit = extract_colon_unit (this_ignoreval, &ptr))
+ #endif
      {
        if (numitems + 1 >= maxitems)
  	{
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/print_cmd.c bash-2.03/print_cmd.c
*** bash203/print_cmd.c	Tue Jan 12 12:46:18 1999
--- bash-2.03/print_cmd.c	Tue Jun 29 20:25:24 1999
***************
*** 39,45 ****
--- 39,49 ----
  #include "bashansi.h"
  
  #include "shell.h"
+ #ifndef HAVE_Y_TAB_H
  #include <y.tab.h>	/* use <...> so we pick it up from the build directory */
+ #else /* Y_TAB_H */
+ #include <y_tab.h>
+ #endif
  #include "stdc.h"
  #include "builtins/common.h"
  
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/readme bash-2.03/readme
*** bash203/readme	Thu Nov 19 11:52:04 1998
--- bash-2.03/readme	Tue Jan 11 16:45:10 2000
***************
*** 69,75 ****
  
  	* the version number and release status of Bash (e.g., 2.01-release)
  	* the machine and OS that it is running on (look at the file
! 	  `.made' in the bash build directory)
  	* a list of the compilation flags or the contents of `config.h', if
  	  appropriate
  	* a description of the bug
--- 69,75 ----
  
  	* the version number and release status of Bash (e.g., 2.01-release)
  	* the machine and OS that it is running on (look at the file
! 	  `_made' in the bash build directory)
  	* a list of the compilation flags or the contents of `config.h', if
  	  appropriate
  	* a description of the bug
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/redir.c bash-2.03/redir.c
*** bash203/redir.c	Thu Jan 29 15:09:16 1998
--- bash-2.03/redir.c	Mon May 17 16:17:48 1999
***************
*** 53,58 ****
--- 53,70 ----
  #  include "input.h"
  #endif
  
+ #if defined (__MSDOS__)
+ #include <stdlib.h>
+ #include <process.h>
+ #include "dosutil.h"
+ #include "trap.h"
+ #if defined (__DJGPP__)
+ #include <dpmi.h>
+ #define dup2 dosutil_dup2_wrapper
+ void __libc_termios_check_signals (void);
+ #endif
+ #endif
+ 
  extern int posixly_correct;
  extern int interactive, interactive_shell;
  extern REDIRECT *redirection_undo_list;
***************
*** 73,78 ****
--- 85,93 ----
     Used to print a reasonable error message. */
  static int heredoc_errno;
  
+ #if defined (__MSDOS__)
+ #endif
+ 
  void
  redirection_error (temp, error)
       REDIRECT *temp;
***************
*** 253,259 ****
--- 268,278 ----
  	 for us rather than managing our own strings.  Most
  	 stdios are not particularly fast, however -- this
  	 may need to be reconsidered later. */
+ #if defined (__MSDOS__)
+       if ((fd2 = dup (fd)) < 0 || (fp = fdopen (fd2, "wt")) == NULL)
+ #else
        if ((fd2 = dup (fd)) < 0 || (fp = fdopen (fd2, "w")) == NULL)
+ #endif
  	{
  	  if (fd2 >= 0)
  	    close (fd2);
***************
*** 292,308 ****
--- 311,348 ----
  here_document_to_fd (redirectee)
       WORD_DESC *redirectee;
  {
+ #if defined (__MSDOS__)
+   char *filename;
+   char *tname;
+   char *tmpdir;
+   int number;
+ #else
    char filename[24];
+ #endif
    int r, fd;
    static int fnum = 0;
  
    do
      {
        /* Make the filename for the temp file. */
+ #if defined (__MSDOS__)
+       tname = xmalloc (dosutil_tmpdir_len + sizeof ("/shXXXXXX"));
+       number = ((int)time ((time_t *) 0) + (int)getpid ()) % 1000000;
+       sprintf (tname, "%s/sh%6.6d", dosutil_tmpdir, number);
+ /*      tname = dosutil_expand_path (tname); */
+       filename = alloca (strlen (tname) + 1);
+       strcpy (filename, tname);
+       free (tname);
+ #else
        sprintf (filename, "/tmp/t%d-%d-sh", (int)getpid (), fnum++);
+ #endif
  
        /* Make sure we open it exclusively. */
+ #if defined (__MSDOS__)
+       fd = open (filename, O_TRUNC | O_WRONLY | O_CREAT | O_EXCL | O_TEXT, 0600);
+ #else
        fd = open (filename, O_TRUNC | O_WRONLY | O_CREAT | O_EXCL, 0600);
+ #endif
      }
    while (fd < 0 && errno == EEXIST);
  
***************
*** 316,321 ****
--- 356,365 ----
      r = write_here_document (fd, redirectee);
  
    close (fd);
+ #if defined (__MSDOS__)
+   if (r == ENOTTY)
+     errno = r = 0;
+ #endif
    if (r)
      {
        unlink (filename);
***************
*** 335,340 ****
--- 379,387 ----
        return -1;
      }
  
+ #if defined (__MSDOS__)
+   dosutil_add_delay_remove (filename);
+ #else
    if (unlink (filename) < 0)
      {
        r = errno;
***************
*** 342,347 ****
--- 389,395 ----
        errno = r;
        return (-1);
      }
+ #endif
  
    return (fd);
  }
***************
*** 527,532 ****
--- 575,583 ----
  	 existing files.  Check before opening. */
        if (noclobber && OUTPUT_REDIRECT (ri))
  	{
+ #if defined (__MSDOS__)
+ 	  redirectee_word = dosutil_expand_path (redirectee_word);
+ #endif
  	  fd = noclobber_open (redirectee_word, redirect->flags, ri);
  	  if (fd == NOCLOBBER_REDIRECT)
  	    {
***************
*** 536,541 ****
--- 587,595 ----
  	}
        else
  	{
+ #if defined (__MSDOS__)
+ 	  redirectee_word = dosutil_expand_path (redirectee_word);
+ #endif
  	  fd = open (redirectee_word, redirect->flags, 0666);
  #if defined (AFS)
  	  if ((fd < 0) && (errno == EACCES))
***************
*** 716,722 ****
--- 770,780 ----
    return (0);
  }
  
+ #if defined (__MSDOS__) && defined (__DJGPP__)
+ #define SHELL_FD_BASE	20
+ #else
  #define SHELL_FD_BASE	10
+ #endif
  
  /* Remember the file descriptor associated with the slot FD,
     on REDIRECTION_UNDO_LIST.  Note that the list will be reversed
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/shell.c bash-2.03/shell.c
*** bash203/shell.c	Thu Feb 18 11:42:26 1999
--- bash-2.03/shell.c	Wed Jun 30 12:09:48 1999
***************
*** 77,82 ****
--- 77,96 ----
  #  include <opennt/opennt.h>
  #endif
  
+ #if defined (__MSDOS__)
+ #include <locale.h>
+ #include "dosutil.h"
+ #if defined (__DJGPP__)
+ #include <time.h>
+ #include <dirent.h>
+ #include <fcntl.h>
+ #include <crt0.h>
+ #define dup2 dosutil_dup2_wrapper
+ extern int __djgpp_set_ctrl_c (int enable);
+ extern int glob_ignore_case;
+ #endif /* !__DJGPP__ */
+ #endif
+ 
  #if !defined (HAVE_GETPW_DECLS)
  extern struct passwd *getpwuid ();
  #endif /* !HAVE_GETPW_DECLS */
***************
*** 99,104 ****
--- 113,123 ----
  extern char *this_command_name;
  extern int array_needs_making;
  
+ #if defined (__DJGPP__)
+ /* Drop .exe from argv[0] */
+ int _crt0_startup_flags = _CRT0_FLAG_DROP_EXE_SUFFIX;
+ #endif
+ 
  /* Non-zero means that this shell has already been run; i.e. you should
     call shell_reinitialize () if you need to start afresh. */
  int shell_initialized = 0;
***************
*** 169,174 ****
--- 188,198 ----
  
  /* The name of the .(shell)rc file. */
  static char *bashrc_file = "~/.bashrc";
+ #ifdef __MSDOS__ /* msdos (short file names) cannot begin with a '.' */
+ const char *dos_orig_bashrc_file = "~/.bashrc";
+ char *dos_bashrc_file = "~/_bashrc";
+ char *dos_profile = "~/_profile";
+ #endif
  
  /* Non-zero means to act more like the Bourne shell on startup. */
  static int act_like_sh;
***************
*** 302,307 ****
--- 326,365 ----
    env = environ;
  #endif /* __OPENNT */
  
+ #if defined (__MSDOS__)
+   extern char **environ;
+   /* initialize and patch */
+   setlocale (LC_CTYPE, ""); /* Unnecessary? */
+   dosutil_import_environment_variables ();
+   dosutil_set_tmpdir(argv[0]);
+   if (dosutil_tmpdir_len == 0)
+   {
+     report_error("unable to find a temporary directory");
+     exit (EX_NOTFOUND);
+   }
+   env = environ;
+ 
+ /*  dosutil_toslash (argv[0]); */
+   dosutil_delete_sysroot (argv[0]);
+   dosutil_reserve_fds ();
+   dosutil_save_cwd ();
+ 
+   /* The .exe isn't removed when Bash involkes itself. */
+   {
+     char *bash = basename(argv[0]);
+     char *dot = strchr(bash, '.');
+     if (dot)
+       *dot = '\0';
+   }
+ 
+ #if defined (__DJGPP__)
+   /* start countup */
+   (void) clock ();
+   /* always disable */
+   (void) __djgpp_set_ctrl_c (0);
+ #endif /* !__DJGPP__ */
+ #endif /* !__MSDOS__ */
+ 
    /* Catch early SIGINTs. */
    code = setjmp (top_level);
    if (code)
***************
*** 437,442 ****
--- 495,501 ----
    else
      init_noninteractive ();
  
+ #if !defined (__MSDOS__)
  #define CLOSE_FDS_AT_LOGIN
  #if defined (CLOSE_FDS_AT_LOGIN)
    /*
***************
*** 452,457 ****
--- 511,517 ----
  	close (i);
      }
  #endif /* CLOSE_FDS_AT_LOGIN */
+ #endif /* __MSDOS__ */
  
    /* If we're in a strict Posix.2 mode, turn on interactive comments and
       other Posix.2 things. */
***************
*** 593,603 ****
--- 653,671 ----
    else if (interactive == 0)
      /* In this mode, bash is reading a script from stdin, which is a
         pipe or redirected file. */
+ #if defined (__MSDOS__)
+     {
+       fflush (stdin);
+       setmode (fileno (stdin), O_TEXT);
+ #endif /* !__MSDOS__ */
  #if defined (BUFFERED_INPUT)
      default_buffered_input = fileno (stdin);	/* == 0 */
  #else
      setbuf (default_input, (char *)NULL);
  #endif /* !BUFFERED_INPUT */
+ #if defined (__MSDOS__)
+     }
+ #endif /* !__MSDOS__ */
  
    set_bash_input ();
  
***************
*** 880,886 ****
--- 948,960 ----
  	  maybe_execute_file (SYS_BASHRC, 1);
  #  endif
  #endif
+ #ifndef __MSDOS__
  	  maybe_execute_file (bashrc_file, 1);
+ #else
+ 	  if ( (maybe_execute_file (bashrc_file, 1) == 0)
+ 	       && (strcmp(dos_orig_bashrc_file, bashrc_file) == 0))
+             maybe_execute_file (dos_bashrc_file, 1);
+ #endif
  	  return;
  	}
      }
***************
*** 904,913 ****
--- 978,1005 ----
  	  maybe_execute_file (SYS_PROFILE, 1);
  
  	  if (act_like_sh)	/* sh */
+ #if defined (__MSDOS__)
+ 	    {
+ 	      if (maybe_execute_file ("~/.profile", 1) == 0)
+ 		maybe_execute_file ("~/_profile", 1);
+ 	    }
+ #else
  	    maybe_execute_file ("~/.profile", 1);
+ #endif
+ #if defined (__MSDOS__)
+ 	  else if ((maybe_execute_file ("~/.bash_profile", 1) == 0) &&
+ 		   (maybe_execute_file ("~/_bash_profile", 1) == 0) &&
+ 		   (maybe_execute_file ("~/_bprof", 1) == 0) &&
+ 		   (maybe_execute_file ("~/.bash_login", 1) == 0) &&
+ 		   (maybe_execute_file ("~/_bash_login", 1) == 0) &&
+ 		   (maybe_execute_file ("~/_blogin", 1) == 0) &&
+ 		   (maybe_execute_file ("~/.profile", 1) == 0))
+ 	    maybe_execute_file ("~/_profile", 1);
+ #else
  	  else if ((maybe_execute_file ("~/.bash_profile", 1) == 0) &&
  		   (maybe_execute_file ("~/.bash_login", 1) == 0))	/* bash */
  	    maybe_execute_file ("~/.profile", 1);
+ #endif
  	}
  
        sourced_login = 1;
***************
*** 940,949 ****
--- 1032,1056 ----
  	      maybe_execute_file (SYS_PROFILE, 1);
  
  	      if (act_like_sh)	/* sh */
+ #if !defined(__MSDOS__)
  		maybe_execute_file ("~/.profile", 1);
  	      else if ((maybe_execute_file ("~/.bash_profile", 1) == 0) &&
  		       (maybe_execute_file ("~/.bash_login", 1) == 0))	/* bash */
  		maybe_execute_file ("~/.profile", 1);
+ #else
+               {
+                 if (maybe_execute_file ("~/.profile", 1) == 0)
+                   maybe_execute_file ("~/_profile", 1);
+               }
+             else if ((maybe_execute_file ("~/.bash_profile", 1) == 0)
+                    && (maybe_execute_file ("~/_bash_profile", 1) == 0)
+                    && (maybe_execute_file ("~/_bprof", 1) == 0)
+                    && (maybe_execute_file ("~/.bash_login", 1) == 0)
+                    && (maybe_execute_file ("~/_bash_login", 1) == 0)
+                    && (maybe_execute_file ("~/_blogin", 1) == 0)
+                    && (maybe_execute_file ("~/.profile", 1) == 0))
+                        maybe_execute_file ("~/_profile", 1);
+ #endif
  	    }
  	}
  
***************
*** 955,963 ****
  	  maybe_execute_file (_prefixInstallPath(SYS_BASHRC, NULL, 0), 1);
  #  else
  	  maybe_execute_file (SYS_BASHRC, 1);
! #  endif`
  #endif
            maybe_execute_file (bashrc_file, 1);
  	}
        /* sh */
        else if (act_like_sh && privileged_mode == 0 && sourced_env++ == 0)
--- 1062,1076 ----
  	  maybe_execute_file (_prefixInstallPath(SYS_BASHRC, NULL, 0), 1);
  #  else
  	  maybe_execute_file (SYS_BASHRC, 1);
! #  endif
  #endif
+ #if !defined(__MSDOS__)
            maybe_execute_file (bashrc_file, 1);
+ #else
+ 	  if ( (maybe_execute_file (bashrc_file, 1) == 0)
+ 	       && (strcmp(dos_orig_bashrc_file, bashrc_file) == 0))
+             maybe_execute_file (dos_bashrc_file, 1);
+ #endif
  	}
        /* sh */
        else if (act_like_sh && privileged_mode == 0 && sourced_env++ == 0)
***************
*** 1204,1210 ****
--- 1317,1327 ----
    dollar_vars[0] = savestring (script_name);
    filename = savestring (script_name);
  
+ #if defined (__MSDOS__)
+   fd = open (filename, O_RDONLY | O_TEXT);
+ #else
    fd = open (filename, O_RDONLY);
+ #endif
    if ((fd < 0) && (errno == ENOENT) && (absolute_program (filename) == 0))
      {
        e = errno;
***************
*** 1215,1221 ****
--- 1332,1342 ----
  	{
  	  free (filename);
  	  filename = path_filename;
+ #if defined (__MSDOS__)
+ 	  fd = open (filename, O_RDONLY | O_TEXT);
+ #else
  	  fd = open (filename, O_RDONLY);
+ #endif
  	}
        else
  	errno = e;
***************
*** 1273,1279 ****
--- 1394,1404 ----
       not match with ours. */
    fd = move_to_high_fd (fd, 0, -1);
  
+ #if defined (__MSDOS__)
+   default_input = fdopen (fd, "rt");
+ #else
    default_input = fdopen (fd, "r");
+ #endif
  
    if (default_input == 0)
      {
***************
*** 1374,1382 ****
--- 1499,1515 ----
    shell_name = base_pathname (argv0);
    if (*shell_name == '-')
      shell_name++;
+ #if defined (__MSDOS__)
+   if (stricmp (shell_name, "sh") == 0 || stricmp (shell_name, "sh.exe") == 0)
+ #else
    if (shell_name[0] == 's' && shell_name[1] == 'h' && shell_name[2] == '\0')
+ #endif
      act_like_sh++;
+ #if defined (__MSDOS__)
+   if (stricmp (shell_name, "su") == 0 || stricmp (shell_name, "su.exe") == 0)
+ #else
    if (shell_name[0] == 's' && shell_name[1] == 'u' && shell_name[2] == '\0')
+ #endif
      su_shell++;
  
    shell_name = argv0;
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/sig.c bash-2.03/sig.c
*** bash203/sig.c	Mon Sep 29 13:00:02 1997
--- bash-2.03/sig.c	Thu Apr  8 00:17:18 1999
***************
*** 50,55 ****
--- 50,59 ----
  #  include "bashhist.h"
  #endif
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
  extern int last_command_exit_value;
  extern int return_catch_flag;
  extern int loop_level, continuing, breaking;
***************
*** 272,278 ****
--- 276,284 ----
       to child processes.  Children will never block SIGCHLD, though. */
    sigemptyset (&top_level_mask);
    sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &top_level_mask);
+ #if !defined (__MSDOS__) || defined (SIGCHLD)
    sigdelset (&top_level_mask, SIGCHLD);
+ #endif
  #endif /* JOB_CONTROL || HAVE_POSIX_SIGNALS */
  
    /* And, some signals that are specifically ignored by the shell. */
***************
*** 417,422 ****
--- 423,434 ----
  
    run_exit_trap ();
    set_signal_handler (sig, SIG_DFL);
+ 
+ #ifdef __DJGPP__
+   if (sig == SIGINT)
+     __asm__ __volatile__ ("movb $0x79,%al;call ___djgpp_hw_exception");
+   else
+ #endif
    kill (getpid (), sig);
  
    SIGRETURN (0);
***************
*** 427,436 ****
--- 439,465 ----
  sigint_sighandler (sig)
       int sig;
  {
+ #if defined (__DJGPP__)
+   (void) __djgpp_set_ctrl_c (0);
+ #endif
  #if defined (MUST_REINSTALL_SIGHANDLERS)
    signal (sig, sigint_sighandler);
  #endif
  
+ #if defined (__MSDOS__)
+ #define SIG_TRAPPED     0x1	/* Currently trapped. */
+ #define SIG_INPROGRESS  0x10	/* Signal handler currently executing. */
+   {
+     extern int dosutil_get_signal_modes (int);
+     extern int dosutil_set_signal_modes (int, int);
+     int modes;
+ 
+     modes = dosutil_get_signal_modes (SIGINT);
+     if (interrupt_state == 0 && interrupt_immediately == 0
+         && (modes & (SIG_INPROGRESS | SIG_TRAPPED)) == (SIG_INPROGRESS | SIG_TRAPPED))
+       dosutil_set_signal_modes (SIGINT, modes & ~SIG_INPROGRESS);
+   }
+ #endif
    /* interrupt_state needs to be set for the stack of interrupts to work
       right.  Should it be set unconditionally? */
    if (interrupt_state == 0)
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/stringlib.c bash-2.03/stringlib.c
*** bash203/stringlib.c	Wed Feb  4 15:20:56 1998
--- bash-2.03/stringlib.c	Fri Feb 19 17:42:08 1999
***************
*** 33,38 ****
--- 33,43 ----
  
  #include "shell.h"
  
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ 
  #ifndef to_upper
  #  define to_upper(c) (islower(c) ? toupper(c) : (c))
  #  define to_lower(c) (isupper(c) ? tolower(c) : (c))
***************
*** 67,72 ****
--- 72,85 ----
    for (r = ret, s = string; s && *s; )
      {
        c = *s++;
+ #if defined (USE_MULTIBYTE)
+       if (_ismbblead (c) && *s != '\0')
+ 	{
+ 	  *r++ = c;
+ 	  *r++ = *s++;
+ 	  continue;
+ 	}
+ #endif
        if (c != '\\' || *s == '\0')
          *r++ = c;
        else
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/subst.c bash-2.03/subst.c
*** bash203/subst.c	Wed Jan 20 12:13:52 1999
--- bash-2.03/subst.c	Mon Aug 30 19:48:02 1999
***************
*** 53,58 ****
--- 53,71 ----
  #include <tilde/tilde.h>
  #include <glob/fnmatch.h>
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #if defined (__DJGPP__)
+ void __libc_termios_check_signals (void);
+ #define dup2 dosutil_dup2_wrapper
+ #endif
+ #endif
+ 
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ 
  #if !defined (errno)
  extern int errno;
  #endif /* !errno */
***************
*** 130,135 ****
--- 143,149 ----
  static char *extract_delimited_string ();
  static char *extract_dollar_brace_string ();
  
+ 
  /* **************************************************************** */
  /*								    */
  /*			Utility Functions			    */
***************
*** 206,211 ****
--- 220,235 ----
  
    for (p = s; *p; p++)
      {
+ #if defined (USE_MULTIBYTE)
+       if (_ismbblead (c))
+ 	{
+ 	  if (p[1] != '\0')
+ 	    p++;
+ 	  else
+ 	    break;
+ 	  continue;
+ 	}
+ #endif
        if (((flags & ST_BACKSL) && *p == '\\')
  	    || ((flags & ST_CTLESC) && *p == CTLESC))
  	{
***************
*** 228,242 ****
--- 252,285 ----
       char *string;
  {
    int sindex, c;
+ #if defined (USE_MULTIBYTE)
+   int skip_next = 0;
+ #endif
  
    for (sindex = 0; c = string[sindex]; )
      {
+ #if defined (USE_MULTIBYTE)
+       if (skip_next)
+ 	{
+ 	  skip_next = 0;
+ 	  goto next_character;
+ 	}
+ 
+       if (_ismbblead (c))
+ 	{
+ 	  skip_next = 1;
+ 	  goto next_character;
+ 	}
+ #endif
        if (c == character)
  	return (1);
  
        switch (c)
  	{
  	default:
+ #if defined (USE_MULTIBYTE)
+ next_character:
+ #endif
  	  sindex++;
  	  break;
  
***************
*** 264,269 ****
--- 307,315 ----
       char *substr, *string;
  {
    int sindex, c, sublen;
+ #if defined (USE_MULTIBYTE)
+   int skip_next = 0;
+ #endif
  
    if (substr == 0 || *substr == '\0')
      return (0);
***************
*** 271,276 ****
--- 317,335 ----
    sublen = strlen (substr);
    for (sindex = 0; c = string[sindex]; )
      {
+ #if defined (USE_MULTIBYTE)
+       if (skip_next)
+ 	{
+ 	  skip_next = 0;
+ 	  goto next_character;
+ 	}
+ 
+       if (_ismbblead (c))
+ 	{
+ 	  skip_next = 1;
+ 	  goto next_character;
+ 	}
+ #endif
        if (STREQN (string + sindex, substr, sublen))
  	return (1);
  
***************
*** 292,297 ****
--- 351,359 ----
  	  break;
  
  	default:
+ #if defined (USE_MULTIBYTE)
+ next_character:
+ #endif
  	  sindex++;
  	  break;
  	}
***************
*** 369,374 ****
--- 431,447 ----
  
    for (i = *sindex; c = string[i]; i++)
      {
+ #if defined (USE_MULTIBYTE)
+       if (_ismbblead (c))
+ 	{
+ 	  if (string[i + 1])
+ 	    i++;
+ 	  else
+ 	    break;
+ 	  i++;
+ 	  continue;
+ 	}
+ #endif
        if (c == '\\')
  	if (string[i + 1])
  	  i++;
***************
*** 450,455 ****
--- 523,544 ----
  	  continue;
  	}
  
+ #if defined (USE_MULTIBYTE)
+       if (_ismbblead (c))
+ 	{
+ 	  temp[j++] = c;
+ 	  c = string[i + 1];
+ 	  if (c)
+ 	    {
+ 	      temp[j++] = c;
+ 	      i++;
+ 	    }
+ 	  else
+ 	    break;
+ 	  continue;
+ 	}
+ #endif
+ 
        /* A backslash protects the next character.  The code just above
  	 handles preserving the backslash in front of any character but
  	 a double quote. */
***************
*** 546,551 ****
--- 635,650 ----
  	  pass_next = 0;
  	  continue;
  	}
+ #if defined (USE_MULTIBYTE)
+       else if (_ismbblead (c))
+ 	{
+ 	  if (string[i+1] != '\0')
+ 	    i++;
+ 	  else
+ 	    break;
+ 	  continue;
+ 	}
+ #endif
        else if (c == '\\')
  	{
  	  pass_next++;
***************
*** 754,759 ****
--- 853,874 ----
  	  continue;
  	}
  
+ #if defined (USE_MULTIBYTE)
+       if (_ismbblead (c))
+ 	{
+ 	  pass_character++;
+ 	  continue;
+ 	}
+ #endif
+ 
+ #if defined (USE_MULTIBYTE)
+       if (_ismbblead (c))
+ 	{
+ 	  pass_character++;
+ 	  continue;
+ 	}
+ #endif
+ 
        if (c == CTLESC)
  	{
  	  pass_character++;
***************
*** 957,962 ****
--- 1072,1088 ----
    register int i, l;
  
    for (i = 0, l = strlen (string); i < l; i++)
+ #if defined (USE_MULTIBYTE)
+     if (_ismbblead (string[i]))
+       {
+ 	if (i+1 < l)
+ 	  i++;
+ 	else
+ 	  break;
+ 	continue;
+       }
+     else
+ #endif
      if (string[i] == '\\' && (string[i + 1] == '`' || string[i + 1] == '\\' ||
  			      string[i + 1] == '$'))
        strcpy (string + i, string + i + 1);	/* XXX - should be memmove */
***************
*** 1014,1019 ****
--- 1140,1152 ----
  	    CQ_RETURN(1);
  	  continue;
  	}
+ #if defined (USE_MULTIBYTE)
+       else if (_ismbblead (string[i]))
+ 	{
+ 	  pass_next = 1;
+ 	  continue;
+ 	}
+ #endif
        else if (string[i] == '\'' || string[i] == '"')
  	{
  	  i = (string[i] == '\'') ? skip_single_quoted (string, ++i)
***************
*** 1049,1054 ****
--- 1182,1194 ----
  	    return 0;
  	  continue;
  	}
+ #if defined (USE_MULTIBYTE)
+       else if (_ismbblead (string[i]))
+ 	{
+ 	  pass_next = 1;
+ 	  continue;
+ 	}
+ #endif
        else if (STREQN (string + i, openstr, olen))
  	{
  	  openc = 1 - openc;
***************
*** 1293,1298 ****
--- 1433,1444 ----
  #else
  	  result = add_string_to_list (current_word, result);
  #endif	  
+ #if defined (__MSDOS__)
+ 	  /* expand each word */
+ 	  if ((!quoted && current_word[0] == '/')
+ 	      || (quoted && current_word[0] == CTLESC && current_word[1] == '/'))
+ 	    result->word->flags |= W_PATHEXPANSION;
+ #endif
  	  if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))
  	    result->word->flags |= W_QUOTED;
  	}
***************
*** 1425,1430 ****
--- 1571,1586 ----
    while (1)
      {
        c = s[i];
+ #if defined (USE_MULTIBYTE)
+       if (_ismbblead (c))
+ 	{
+ 	  if (s[i+1] != '\0')
+ 	    {
+ 	      i++;
+ 	      continue;
+ 	    }
+ 	}
+ #endif
        if (c == '\\')
  	{
  	  i++;
***************
*** 1752,1757 ****
--- 1908,1923 ----
  
    for (i = saw_quote = 0; string[i]; i++)
      {
+ #if defined (USE_MULTIBYTE)
+       if (_ismbblead (string[i]))
+ 	{
+ 	  if (string[i + 1])
+ 	    i++;
+ 	  else
+ 	    break;
+ 	  continue;
+ 	}
+ #endif
        if (EXP_CHAR (string[i]))
  	break;
        else if (string[i] == '\'' || string[i] == '\\' || string[i] == '"')
***************
*** 2754,2759 ****
--- 2920,2947 ----
    nfifo = 0;
  }
  
+ #if defined (__MSDOS__)
+ static char *
+ make_named_pipe ()
+ {
+   char *tname;
+   int fd;
+ 
+   tname = xmalloc (dosutil_tmpdir_len + sizeof ("/npXXXXXX"));
+   sprintf (tname, "%s/npXXXXXX", dosutil_tmpdir);
+   tname = mktemp (dosutil_expand_path (tname));
+   if ((fd = creat (tname, 0600)) < 0)
+     {
+       free (tname);
+       return ((char *)NULL);
+     }
+   else
+     close (fd);
+ 
+   add_fifo_list (tname);
+   return (tname);
+ }
+ #else /* !__MSDOS__ */
  static char *
  make_named_pipe ()
  {
***************
*** 2769,2774 ****
--- 2957,2963 ----
    add_fifo_list (tname);
    return (tname);
  }
+ #endif /* !__MSDOS__ */
  
  #else /* HAVE_DEV_FD */
  
***************
*** 2880,2885 ****
--- 3069,3077 ----
  #if defined (JOB_CONTROL)
    pid_t old_pipeline_pgrp;
  #endif
+ #if defined (__MSDOS__)
+   OLDENVBUF oldenvbuf;
+ #endif
  
    if (!string || !*string || wordexp_only)
      return ((char *)NULL);
***************
*** 2887,2893 ****
--- 3079,3089 ----
  #if !defined (HAVE_DEV_FD)
    pathname = make_named_pipe ();
  #else /* HAVE_DEV_FD */
+ #if defined (__MSDOS__)
+   if (dosutil_pipe (fildes) < 0)
+ #else
    if (pipe (fildes) < 0)
+ #endif
      {
        sys_error ("cannot make pipe for process substitution");
        return ((char *)NULL);
***************
*** 2921,2933 ****
--- 3117,3138 ----
  #endif
  #endif /* JOB_CONTROL */
  
+ #if defined (__MSDOS__)
+   dosutil_save_all_environment (&oldenvbuf);
+ #endif
    pid = make_child ((char *)NULL, 1);
+ #if defined (__MSDOS__)
+   if (pid > 0)
+ #else
    if (pid == 0)
+ #endif
      {
+ #if !defined (__MSDOS__)
        reset_terminating_signals ();	/* XXX */
        /* Cancel traps, in trap.c. */
        restore_original_signals ();
        setup_async_signals ();
+ #endif
        subshell_environment = SUBSHELL_COMSUB;
      }
  
***************
*** 2945,2955 ****
--- 3150,3170 ----
        close (parent_pipe_fd);
        close (child_pipe_fd);
  #endif /* HAVE_DEV_FD */
+ #if defined (__MSDOS__)
+       dosutil_restore_all_environment (&oldenvbuf);
+ #endif
        return ((char *)NULL);
      }
  
+ #if defined (__MSDOS__)
+   if (pid == 0)
+     {
+       /* parent side */
+       process_substitute_parent:
+ #else
    if (pid > 0)
      {
+ #endif
  #if defined (JOB_CONTROL)
        restore_pipeline (1);
  #endif
***************
*** 2980,2986 ****
--- 3195,3206 ----
      {
        sys_error ("cannot open named pipe %s for %s", pathname,
  	open_for_read_in_child ? "reading" : "writing");
+ #if defined (__MSDOS__)
+       dosutil_wait_status = 127;
+       goto process_substitute_exit;
+ #else
        exit (127);
+ #endif
      }
  #else /* HAVE_DEV_FD */
    fd = child_pipe_fd;
***************
*** 2990,2996 ****
--- 3210,3221 ----
      {
        sys_error ("cannot duplicate named pipe %s as fd %d", pathname,
  	open_for_read_in_child ? 0 : 1);
+ #if defined (__MSDOS__)
+       dosutil_wait_status = 127;
+       goto process_substitute_exit;
+ #else
        exit (127);
+ #endif
      }
  
    close (fd);
***************
*** 3018,3025 ****
--- 3243,3260 ----
    close (open_for_read_in_child ? 0 : 1);
  #endif /* !HAVE_DEV_FD */
  
+ #if defined (__MSDOS__)
+   dosutil_wait_status = result;
+ 
+ process_substitute_exit:
+   dosutil_restore_all_environment (&oldenvbuf);
+ 
+   /* run parent side */
+   goto process_substitute_parent;
+ #else
    exit (result);
    /*NOTREACHED*/
+ #endif
  }
  #endif /* PROCESS_SUBSTITUTION */
  
***************
*** 3108,3113 ****
--- 3343,3352 ----
    pid_t pid, old_pid, old_pipeline_pgrp;
    char *istring;
    int result, fildes[2];
+ #if defined (__MSDOS__)
+   int pipes = dosutil_pipe_no ();
+   OLDENVBUF oldenvbuf;
+ #endif
  
    istring = (char *)NULL;
  
***************
*** 3123,3130 ****
--- 3362,3377 ----
      }
  
    /* Pipe the output of executing STRING into the current shell. */
+ #if defined (__MSDOS__)
+   if (dosutil_pipe (fildes) < 0)
+ #else
    if (pipe (fildes) < 0)
+ #endif
      {
+ #if defined (__MSDOS__)
+       fildes[0] = -1;
+       fildes[1] = -1;
+ #endif
        sys_error ("cannot make pipes for command substitution");
        goto error_exit;
      }
***************
*** 3136,3146 ****
--- 3383,3398 ----
    cleanup_the_pipeline ();
  #endif
  
+ #if defined (__MSDOS__)
+   dosutil_save_all_environment (&oldenvbuf);
+ #endif
    pid = make_child ((char *)NULL, 0);
+ #if !defined (__MSDOS__)
    if (pid == 0)
      /* Reset the signal handlers in the child, but don't free the
         trap strings. */
      reset_signal_handlers ();
+ #endif
  
  #if defined (JOB_CONTROL)
    set_sigchld_handler ();
***************
*** 3152,3165 ****
--- 3404,3439 ----
      {
        sys_error ("cannot make child for command substitution");
      error_exit:
+ #if defined (__MSDOS__)
+       dosutil_restore_all_environment (&oldenvbuf);
+     error_exit_without_restore:
+ #endif
  
        FREE (istring);
+ #if defined (__MSDOS__)
+       if (fildes[0] >= 0)
+ 	{
+ 	  close (fildes[0]);
+ 	  fildes[0] = -1;
+ 	}
+       if (fildes[1] >= 0)
+ 	{
+ 	  close (fildes[1]);
+ 	  fildes[1] = -1;
+ 	}
+       dosutil_pipe_clean (pipes);
+ #else
        close (fildes[0]);
        close (fildes[1]);
+ #endif
        return ((char *)NULL);
      }
  
+ #if defined (__MSDOS__)
+   if (pid > 0)
+ #else
    if (pid == 0)
+ #endif
      {
        set_sigint_handler ();	/* XXX */
  #if defined (JOB_CONTROL)
***************
*** 3168,3176 ****
--- 3442,3456 ----
        if (dup2 (fildes[1], 1) < 0)
  	{
  	  sys_error ("command_substitute: cannot duplicate pipe as fd 1");
+ #if defined (__MSDOS__)
+ 	  dosutil_wait_status = (EXECUTION_FAILURE);
+ 	  goto error_exit;
+ #else
  	  exit (EXECUTION_FAILURE);
+ #endif
  	}
  
+ #if !defined (__MSDOS__)
        /* If standard output is closed in the parent shell
  	 (such as after `exec >&-'), file descriptor 1 will be
  	 the lowest available file descriptor, and end up in
***************
*** 3186,3191 ****
--- 3466,3472 ----
  	  (fildes[0] != fileno (stdout)) &&
  	  (fildes[0] != fileno (stderr)))
  	close (fildes[0]);
+ #endif
  
        /* The currently executing shell is not interactive. */
        interactive = 0;
***************
*** 3203,3226 ****
--- 3484,3539 ----
  	 so we don't go back up to main (). */
        result = setjmp (top_level);
  
+ #if defined (__MSDOS__)
+       if (result == EXITPROG)
+ 	{
+ 	  dosutil_wait_status = (last_command_exit_value);
+ 	  goto error_exit;
+ 	}
+       else if (result)
+ 	{
+ 	  dosutil_wait_status = (EXECUTION_FAILURE);
+ 	  goto error_exit;
+ 	}
+       else
+         dosutil_wait_status = (parse_and_execute (string, "command substitution", SEVAL_NOHIST));
+ 
+       dosutil_restore_all_environment (&oldenvbuf);
+ 
+       /* run parent side */
+       goto command_substitute_parent;
+ #else /* !__MSDOS__ */
        if (result == EXITPROG)
  	exit (last_command_exit_value);
        else if (result)
  	exit (EXECUTION_FAILURE);
        else
  	exit (parse_and_execute (string, "command substitution", SEVAL_NOHIST));
+ #endif
      }
    else
      {
+ #if defined (__MSDOS__)
+ command_substitute_parent:
+       /* reset file pointer */
+       lseek (fildes[0], 0, SEEK_SET);
+ #endif
  #if defined (JOB_CONTROL) && defined (PGRP_PIPE)
        close_pgrp_pipe ();
  #endif /* JOB_CONTROL && PGRP_PIPE */
  
        close (fildes[1]);
+ #if defined (__MSDOS__)
+       fildes[1] = -1;
+ #endif
  
        istring = read_comsub (fildes[0], quoted);
  
        close (fildes[0]);
+ #if defined (__MSDOS__)
+       fildes[0] = -1;
+       dosutil_pipe_clean (pipes);
+ #endif
  
        current_command_subst_pid = pid;
        last_command_exit_value = wait_for (pid);
***************
*** 4176,4181 ****
--- 4489,4500 ----
    int want_substring, want_indir, want_patsub;
    char *name, *value, *temp, *temp1;
    int t_index, sindex, c, number;
+ #if defined (USE_MULTIBYTE)
+   int skip_next = 0;
+ #endif
+ #if defined (__MSDOS__)
+   int need_expand_path = 0;
+ #endif
  
    value = (char *)NULL;
    var_is_set = var_is_null = var_is_special = check_nullness = 0;
***************
*** 4491,4496 ****
--- 4810,4818 ----
    int zindex, number, c, t_index, expok;
    SHELL_VAR *var;
    WORD_LIST *list, *tlist;
+ #if defined (USE_MULTIBYTE)
+   int skip_next = 0;
+ #endif
  
    zindex = *sindex;
    c = string[++zindex];
***************
*** 4695,4701 ****
--- 5017,5026 ----
  
  comsub:
        temp1 = command_substitute (temp, quoted);
+ #if !defined (__MSDOS__)
+ /* Already free'd by parse_and_execute().  */
        FREE (temp);
+ #endif
        temp = temp1;
        break;
  
***************
*** 4850,4855 ****
--- 5175,5186 ----
    register int c;		/* Current character. */
    int number;			/* Temporary number value. */
    int t_index;			/* For calls to string_extract_xxx. */
+ #if defined (USE_MULTIBYTE)
+   int skip_next = 0;
+ #endif
+ #if defined (__MSDOS__)
+   int need_expand_path = 0;
+ #endif
  
    char ifscmap[256];
  
***************
*** 4877,4883 ****
         ${abc:-G { I } K } as one word when it should be three. */
      if (*temp1 != ' ' && *temp1 != '\t' && *temp1 != '\n')
  #endif
!       ifscmap[*temp1] = 1;
  
    /* Begin the expansion. */
  
--- 5208,5214 ----
         ${abc:-G { I } K } as one word when it should be three. */
      if (*temp1 != ' ' && *temp1 != '\t' && *temp1 != '\n')
  #endif
!       ifscmap[(unsigned char)*temp1] = 1;
  
    /* Begin the expansion. */
  
***************
*** 4885,4890 ****
--- 5216,5234 ----
      {
        c = string[sindex];
  
+ #if defined (USE_MULTIBYTE)
+       if (skip_next)
+ 	{
+ 	  skip_next = 0;
+ 	  goto add_character;
+ 	}
+ 
+       if (_ismbblead (c))
+ 	{
+ 	  skip_next = 1;
+ 	  goto add_character;
+ 	}
+ #endif
        /* Case on toplevel character. */
        switch (c)
  	{
***************
*** 4900,4905 ****
--- 5244,5254 ----
  dollar_add_string:
  	  if (string[sindex])
  	    sindex++;
+ #if defined (__MSDOS__)
+           if (temp && istring_index == 0
+             && (temp[0] == '/' || (temp[0] == CTLESC && temp[1] == '/')))
+ 		need_expand_path = 1;
+ #endif
  
  add_string:
  	  if (temp)
***************
*** 4956,4961 ****
--- 5305,5311 ----
  	    }
  	  if (contains_dollar_at && has_dollar_at)
  	    *contains_dollar_at = 1;
+ 
  	  goto add_string;
  	  break;
  
***************
*** 4969,4976 ****
--- 5319,5334 ----
  	    temp = string_extract (string, &sindex, "`", 0);
  	    de_backslash (temp);
  	    temp1 = command_substitute (temp, quoted);
+ #if !defined (__MSDOS__)
+ 	    /* freed by parse_and_execute() */
  	    FREE (temp);
+ #endif
  	    temp = temp1;
+ #if defined (__MSDOS__)
+ 	    if (temp && istring_index == 0
+ 		&& (temp[0] == '/' || (temp[0] == CTLESC && temp[1] == '/')))
+ 	      need_expand_path = 1;
+ #endif
  	    goto dollar_add_string;
  	  }
  
***************
*** 5009,5014 ****
--- 5367,5376 ----
  
  	  t_index = ++sindex;
  	  temp = string_extract_double_quoted (string, &sindex, 0);
+ #if defined (__MSDOS__)
+ 	  if (temp && istring_index == 0 && temp[0] == '/')
+ 	    need_expand_path = 1;
+ #endif
  
  	  /* If the quotes surrounded the entire string, then the
  	     whole word was quoted. */
***************
*** 5084,5089 ****
--- 5446,5455 ----
  	     as well), so we go directly to add_string. */
  	  if (list)
  	    {
+ #if defined (__MSDOS__)
+ 	      if (list->word->flags & W_PATHEXPANSION)
+ 	        need_expand_path = 1;
+ #endif
  	      if (list->next)
  		{
  		  /* Testing quoted_dollar_at makes sure that "$@" is
***************
*** 5177,5182 ****
--- 5543,5552 ----
  	    }
  
  	add_character:
+ #if defined (__MSDOS__)
+ 	  if (istring_index == 0 && c == '/')
+ 	    need_expand_path = 1;
+ #endif
  	  RESIZE_MALLOCED_BUFFER (istring, istring_index, 1, istring_size,
  				  DEFAULT_ARRAY_SIZE);
  	  istring[istring_index++] = c;
***************
*** 5188,5193 ****
--- 5558,5592 ----
      }
  
  finished_with_string:
+ #if defined (__MSDOS__)
+   if (need_expand_path != 0 && istring && strpbrk (istring, ":;") == NULL)
+     {
+       char tbuf[5] = { 0, 0, 0, 0, 0,};
+       char *p = istring, *q = tbuf;
+       int i;
+ 
+       /* dequote 5 chars */
+       for (i = 0; i < 5; i++)
+ 	{
+ 	  if (*p == CTLESC)
+ 	    p++;
+ 	  if (*p == '\0')
+ 	    break;
+ 	  *q++ = *p++;
+ 	}
+ 
+       /* check whether it's option switch */
+ /*
+       if (tbuf[0] != '/' || (tbuf[1] != '\0' && (tbuf[1] == '/' || tbuf[2] == '\0')
+ 			     && (tbuf[1] != '/' || !isalpha (tbuf[2])
+ 				 || (tbuf[3] != '/' && tbuf[3] != '\0'))))
+ */
+       if (!dosutil_is_dev_path (tbuf))
+ 	need_expand_path = 0;
+     }
+   else
+     need_expand_path = 0;
+ #endif
    /* OK, we're ready to return.  If we have a quoted string, and
       quoted_dollar_at is not set, we do no splitting at all; otherwise
       we split on ' '.  The routines that call this will handle what to
***************
*** 5248,5253 ****
--- 5647,5656 ----
  	tword->flags |= W_ASSIGNMENT;	/* XXX */
        if (word->flags & W_NOGLOB)
  	tword->flags |= W_NOGLOB;	/* XXX */
+ #if defined (__MSDOS__)
+ 	if (need_expand_path)
+ 	  tword->flags |= W_PATHEXPANSION;
+ #endif
        if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
          tword->flags |= W_QUOTED;
      }
***************
*** 5269,5274 ****
--- 5672,5681 ----
  	{
  	  tword = make_bare_word (istring);
  	  list = make_word_list (tword, (WORD_LIST *)NULL);
+ #if defined (__MSDOS__)
+ 	  if (need_expand_path)
+ 	    tword->flags |= W_PATHEXPANSION;
+ #endif
  	  if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || (quoted_state == WHOLLY_QUOTED))
  	    tword->flags |= W_QUOTED;
  	  if (word->flags & W_ASSIGNMENT)
***************
*** 5297,5308 ****
--- 5704,5731 ----
  {
    char *r, *result_string, *temp;
    int sindex, tindex, c, dquote;
+ #if defined (USE_MULTIBYTE)
+   int skip_next = 0;
+ #endif
  
    /* The result can be no longer than the original string. */
    r = result_string = xmalloc (strlen (string) + 1);
  
    for (dquote = sindex = 0; c = string[sindex];)
      {
+ #if defined (USE_MULTIBYTE)
+       if (skip_next)
+ 	{
+ 	  skip_next = 0;
+ 	  goto next_character;
+ 	}
+ 
+       if (_ismbblead (c))
+ 	{
+ 	  skip_next = 1;
+ 	  goto next_character;
+ 	}
+ #endif
        switch (c)
  	{
  	case '\\':
***************
*** 5312,5317 ****
--- 5735,5743 ----
  	  /* FALLTHROUGH */
  
  	default:
+ #if defined (USE_MULTIBYTE)
+ next_character:
+ #endif
  	  *r++ = c;
  	  sindex++;
  	  break;
***************
*** 5472,5479 ****
    if (!tlist)
      return ((WORD_LIST *)NULL);
  
!   if (varlist)
!     dispose_words (varlist);	/* Clean up after previous error */
  
    varlist = (WORD_LIST *)NULL;
    vp = lp = tlist;
--- 5898,5907 ----
    if (!tlist)
      return ((WORD_LIST *)NULL);
  
! #if 0
!  if (varlist)
!     dispose_words (varlist);    /* Clean up after previous error */
! #endif
  
    varlist = (WORD_LIST *)NULL;
    vp = lp = tlist;
***************
*** 5959,5961 ****
--- 6387,6481 ----
  
    return (new_list);
  }
+ 
+ #if defined (__MSDOS__)
+ void
+ sv_path_expand (char *name)
+ {
+   char *p;
+ 
+   p = get_string_value (name);
+   dosutil_path_expand = 0;
+   if (p != NULL)
+     {
+       if (*p == 'y' || *p == 'Y')
+ 	dosutil_path_expand = 1;
+     }
+ }
+ 
+ void
+ sv_path_separator (char *name)
+ {
+   char **vp, *p;
+ 
+   vp = dosutil_get_import_variables ();
+   p = get_string_value (name);
+   dosutil_path_separator = ';';
+   if (p != NULL)
+     {
+       if (*p != '\0' && *p != '/' && *p != '\\' && *p < 0x7f)
+ 	dosutil_path_separator = (int) *(unsigned char *) p;
+     }
+   dosutil_put_export_variables (vp);
+ }
+ 
+ void
+ sv_path_slash (char *name)
+ {
+   char **vp, *p;
+ 
+   vp = dosutil_get_import_variables ();
+   p = get_string_value (name);
+   dosutil_path_slash = '/';
+   if (p != NULL)
+     {
+       if (*p != '\0' && (*p == '/' || *p == '\\') && *p < 0x7f)
+ 	dosutil_path_slash = (int) *(unsigned char *) p;
+     }
+   dosutil_put_export_variables (vp);
+ }
+ 
+ void
+ sv_sysroot (char *name)
+ {
+   char **vp, *p;
+ 
+   vp = dosutil_get_import_variables ();
+   p = get_string_value (name);
+   if (p != NULL && *p != '\0')
+     {
+       if (p[1] == ':' && p[2] == '\0')
+         strcpy (dosutil_sysroot, p);
+       else
+         _fixpath(p, dosutil_sysroot);
+       if (isalpha (dosutil_sysroot[0]) && dosutil_sysroot[1] == ':')
+ 	dosutil_sysroot[0] = tolower (dosutil_sysroot[0]);
+       dosutil_sysroot_len = strlen (dosutil_sysroot);
+       if (dosutil_sysroot[dosutil_sysroot_len - 1] == '/')
+         dosutil_sysroot[--dosutil_sysroot_len] = '\0';
+ 
+       bind_variable("SYSROOT", dosutil_sysroot);
+     }
+   else
+     {
+       dosutil_sysroot[0] = '\0';
+       dosutil_sysroot_len = -1;
+     }
+   dosutil_put_export_variables (vp);
+ }
+ 
+ void
+ sv_test_finds_exe (char *name)
+ {
+   char *p;
+ 
+   p = get_string_value (name);
+   dosutil_test_finds_exe = 0;
+   if (p != NULL)
+     {
+       if (*p == 'y' || *p == 'Y')
+         dosutil_test_finds_exe = 1;
+     }
+ }
+ 
+ #endif
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/subst.h bash-2.03/subst.h
*** bash203/subst.h	Fri Sep 12 16:54:32 1997
--- bash-2.03/subst.h	Thu Jul 29 11:39:42 1999
***************
*** 185,190 ****
--- 185,198 ----
  extern char *cond_expand_word __P((WORD_DESC *, int));
  #endif
  
+ #if defined (__MSDOS__)
+ void sv_path_expand (char *name);
+ void sv_path_separator (char *name);
+ void sv_path_slash (char *name);
+ void sv_sysroot (char *name);
+ void sv_test_finds_exe (char *name);
+ #endif
+ 
  /* How to determine the quoted state of the character C. */
  #define QUOTED_CHAR(c)  ((c) == CTLESC)
  
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/support/missing bash-2.03/support/missing
*** bash203/support/missing	Wed Dec 16 10:47:22 1998
--- bash-2.03/support/missing	Tue Jan 11 16:45:44 2000
***************
*** 39,45 ****
  Supported PROGRAM values:
    aclocal      touch file \`aclocal.m4'
    autoconf     touch file \`configure'
!   autoheader   touch file \`config.h.in'
    automake     touch all \`Makefile.in' files
    bison        create \`y.tab.[ch]', if possible, from existing .[ch]
    flex         create \`lex.yy.c', if possible, from existing .c
--- 39,45 ----
  Supported PROGRAM values:
    aclocal      touch file \`aclocal.m4'
    autoconf     touch file \`configure'
!   autoheader   touch file \`config.h-in'
    automake     touch all \`Makefile.in' files
    bison        create \`y.tab.[ch]', if possible, from existing .[ch]
    flex         create \`lex.yy.c', if possible, from existing .c
***************
*** 89,95 ****
      else
        files=`echo "$files" | sed -e 's/:/ /g'`
      fi
!     test -z "$files" && files="config.h.in"
      touch $files
      ;;
  
--- 89,95 ----
      else
        files=`echo "$files" | sed -e 's/:/ /g'`
      fi
!     test -z "$files" && files="config.h-in"
      touch $files
      ;;
  
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/support/mkclone bash-2.03/support/mkclone
*** bash203/support/mkclone	Thu Apr 11 16:08:58 1996
--- bash-2.03/support/mkclone	Tue Jan 11 16:45:20 2000
***************
*** 87,93 ****
  done < $MANIFEST
  
  # special
! SPECIAL="parser-built y.tab.c y.tab.h"
  
  rm -f $SPECIAL
  for sf in $SPECIAL
--- 87,93 ----
  done < $MANIFEST
  
  # special
! SPECIAL="parser-built y.tab.c y.tab.h y_tab.c y_tab.h"
  
  rm -f $SPECIAL
  for sf in $SPECIAL
***************
*** 96,102 ****
  	$ECHO cp -p $SRCDIR/$sf $TARGET
  done
  
! $ECHO $LN $SRCDIR/.distribution .
! $ECHO $LN $SRCDIR/.patchlevel .
  
  exit 0
--- 96,102 ----
  	$ECHO cp -p $SRCDIR/$sf $TARGET
  done
  
! $ECHO $LN $SRCDIR/_distribution .
! $ECHO $LN $SRCDIR/_patchlevel .
  
  exit 0
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/support/mksignames.c bash-2.03/support/mksignames.c
*** bash203/support/mksignames.c	Wed Jan 20 16:50:20 1999
--- bash-2.03/support/mksignames.c	Fri Feb 19 17:42:10 1999
***************
*** 29,35 ****
--- 29,39 ----
  #endif /* HAVE_STDLIB_H */
  
  #if !defined (NSIG)
+ #if defined (__DJGPP__) && defined (SIGMAX)
+ #define NSIG SIGMAX
+ #else
  #  define NSIG 64
+ #endif
  #endif
  
  char *signal_names[2 * NSIG];
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/support/mkversion.sh bash-2.03/support/mkversion.sh
*** bash203/support/mkversion.sh	Thu Jan 30 14:21:54 1997
--- bash-2.03/support/mkversion.sh	Thu Mar 18 14:45:10 1999
***************
*** 38,45 ****
  fi
  
  build_ver=
! if [ -r .build ]; then
! 	build_ver=`cat .build`
  fi
  if [ -z "$build_ver" ]; then
  	build_ver=0
--- 38,45 ----
  fi
  
  build_ver=
! if [ -r _build ]; then
!         build_ver=`cat _build`
  fi
  if [ -z "$build_ver" ]; then
  	build_ver=0
***************
*** 66,72 ****
  echo "   \`make version.h' to the Makefile.  It is created by mkversion. */"
  
  # Output the distribution version
! float_dist=`echo $dist_version | awk '{printf "%.2f\n", $1}'`
  
  echo
  echo "/* The distribution version number of this shell. */"
--- 66,72 ----
  echo "   \`make version.h' to the Makefile.  It is created by mkversion. */"
  
  # Output the distribution version
! float_dist=`echo $dist_version | gawk '{printf "%.2f\n", $1}'`
  
  echo
  echo "/* The distribution version number of this shell. */"
***************
*** 94,104 ****
  echo "#define SCCSVERSION \"@(#)Bash version ${sccs_string}\""
  
  if [ -n "$inc_build" ]; then
! 	# Make sure we can write to .build
! 	if [ -f .build ] && [ ! -w .build ]; then
! 		echo "$PROGNAME: cannot write to .build, not incrementing build version" >&2
  	else
! 		echo "$build_ver" > .build
  	fi
  fi
  	
--- 94,104 ----
  echo "#define SCCSVERSION \"@(#)Bash version ${sccs_string}\""
  
  if [ -n "$inc_build" ]; then
!         # Make sure we can write to _build
!         if [ -f _build ] && [ ! -w _build ]; then
!                 echo "$PROGNAME: cannot write to _build, not incrementing build version" >&2
  	else
!                 echo "$build_ver" > _build
  	fi
  fi
  	
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/test.c bash-2.03/test.c
*** bash203/test.c	Mon Nov  2 16:21:06 1998
--- bash-2.03/test.c	Thu Jul 29 10:58:18 1999
***************
*** 60,65 ****
--- 60,76 ----
  
  #include <glob/fnmatch.h>
  
+ #if defined (HAVE_STRING_H)
+ #include <string.h>
+ #endif
+ #if defined (HAVE_STDLIB_H)
+ #include <stdlib.h>
+ #endif
+ 
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
  #if !defined (STRLEN)
  #  define STRLEN(s) ((s)[0] ? ((s)[1] ? ((s)[2] ? strlen(s) : 2) : 1) : 0)
  #endif
***************
*** 200,206 ****
--- 211,229 ----
        return (stat (pbuf, finfo));
  #endif /* !HAVE_DEV_FD */
      }
+ #if defined (__MSDOS__)
+   {
+     int rc;
+     char *fixp;
+ 
+     fixp = dosutil_expand_path (savestring (path));
+     rc = stat (fixp, finfo);
+     free (fixp);
+     return rc;
+   }
+ #else
    return (stat (path, finfo));
+ #endif
  }
  
  /* Do the same thing access(2) does, but use the effective uid and gid,
***************
*** 228,233 ****
--- 251,274 ----
  	return (0);
      }
  
+ #if defined (__DJGPP__)
+   switch (mode)
+     {
+       case F_OK:
+       case R_OK:
+         mode = S_IROTH;
+         break;
+       case W_OK:
+         mode = S_IWOTH;
+         break;
+       case X_OK:
+         mode = S_IXOTH;
+         break;
+       default:
+         mode = 0;
+       }
+ #endif
+ 
    if (st.st_uid == current_user.euid)        /* owner */
      mode <<= 6;
    else if (group_member (st.st_gid))
***************
*** 572,584 ****
--- 613,669 ----
        return (test_stat (arg, &stat_buf) == 0);
  
      case 'r':			/* file is readable? */
+ #if defined (__MSDOS__) && 0
+       {
+ 	  int rc = EACCESS (arg, R_OK);
+           if (rc != 0 && dosutil_test_finds_exe && absolute_pathname (arg))
+ 	    {
+ 	      char *name;
+ 	      int len;
+ 
+ 	      len = dosutil_has_suffix (arg);
+ 	      name = malloc (len + 5);
+ 	      if ((name != NULL) && (len > 0))
+ 	        {
+ 	          strcpy (name, arg);
+                 strcpy (name + len, ".exe");
+ 	          rc = EACCESS (name, R_OK);
+ 	          free (name);
+ 	        }
+ 	    }
+ 	  return (rc == 0);
+       }
+ #else
        return (EACCESS (arg, R_OK) == 0);
+ #endif
  
      case 'w':			/* File is writeable? */
        return (EACCESS (arg, W_OK) == 0);
  
      case 'x':			/* File is executable? */
+ #if defined (__MSDOS__)
+       {
+         int rc = EACCESS (arg, X_OK);
+ 	  if (rc != 0)
+ 	    {
+ 	      char *name;
+ 	      int len;
+ 
+ 	      len = strlen (arg);
+ 	      name = malloc (len + 5);
+ 	      if (name != NULL)
+ 	        {
+ 	          strcpy (name, arg);
+                 if (dosutil_add_executable_suffix (name))
+ 	            rc = EACCESS (name, X_OK);
+ 	          free (name);
+ 	        }
+ 	    }
+ 	  return (rc == 0);
+       }
+ #else
        return (EACCESS (arg, X_OK) == 0);
+ #endif
  
      case 'O':			/* File is owned by you? */
        return (test_stat (arg, &stat_buf) == 0 &&
***************
*** 593,601 ****
  	      stat_buf.st_atime <= stat_buf.st_mtime);
  
      case 'f':			/* File is a file? */
        if (test_stat (arg, &stat_buf) < 0)
  	return (FALSE);
! 
        /* -f is true if the given file exists and is a regular file. */
  #if defined (S_IFMT)
        return (S_ISREG (stat_buf.st_mode) || (stat_buf.st_mode & S_IFMT) == 0);
--- 678,708 ----
  	      stat_buf.st_atime <= stat_buf.st_mtime);
  
      case 'f':			/* File is a file? */
+ #if defined (__MSDOS__)
+       {
+ 	  int rc = test_stat (arg, &stat_buf);
+           if ((rc != 0) && dosutil_test_finds_exe && absolute_pathname (arg))
+ 	    {
+ 	      char *name;
+ 	      int len;
+ 
+ 	      len = dosutil_has_suffix (arg);
+ 	      name = malloc (len + 5);
+ 	      if ((name != NULL) && (len > 0))
+ 	        {
+ 	          strcpy (name, arg);
+ 	          strcpy (name + len, ".exe");
+ 	          rc = test_stat (name, &stat_buf);
+ 	          free (name);
+ 	        }
+ 	    }
+ 	  if (rc < 0)
+ 	    return (FALSE);
+       }
+ #else
        if (test_stat (arg, &stat_buf) < 0)
  	return (FALSE);
! #endif
        /* -f is true if the given file exists and is a regular file. */
  #if defined (S_IFMT)
        return (S_ISREG (stat_buf.st_mode) || (stat_buf.st_mode & S_IFMT) == 0);
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/tests/errors.tests bash-2.03/tests/errors.tests
*** bash203/tests/errors.tests	Wed Dec  3 17:33:36 1997
--- bash-2.03/tests/errors.tests	Tue Jan 11 16:45:42 2000
***************
*** 71,77 ****
  # an error, not create an `invisible function'
  export -f XPATH
  
! # this depends on the setting of BREAK_COMPLAINS in config.h.in
  break
  continue
  
--- 71,77 ----
  # an error, not create an `invisible function'
  export -f XPATH
  
! # this depends on the setting of BREAK_COMPLAINS in config.h-in
  break
  continue
  
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/tests/run-minimal bash-2.03/tests/run-minimal
*** bash203/tests/run-minimal	Thu Jul  3 13:11:56 1997
--- bash-2.03/tests/run-minimal	Tue Jan 11 16:45:04 2000
***************
*** 25,31 ****
  	*.orig|*~) ;;
  	run-dollars|run-execscript|run-func|run-getopts|run-heredoc) echo $x ; sh $x ;;
  	run-ifs-tests|run-input-test|run-more-exp|run-nquote|run-posix2) echo $x ; sh $x ;;
! 	run-posixpat) echo $x ; sh $x ;;
  	run-precedence|run-quote|run-read|run-rhs-exp|run-strip|run-tilde) echo $x ; sh $x ;;
  	*)	;;
  	esac
--- 25,31 ----
  	*.orig|*~) ;;
  	run-dollars|run-execscript|run-func|run-getopts|run-heredoc) echo $x ; sh $x ;;
  	run-ifs-tests|run-input-test|run-more-exp|run-nquote|run-posix2) echo $x ; sh $x ;;
! 	run-psxpat) echo $x ; sh $x ;;
  	run-precedence|run-quote|run-read|run-rhs-exp|run-strip|run-tilde) echo $x ; sh $x ;;
  	*)	;;
  	esac
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/trap.c bash-2.03/trap.c
*** bash203/trap.c	Thu Oct 22 13:39:06 1998
--- bash-2.03/trap.c	Fri Feb 19 17:42:10 1999
***************
*** 36,41 ****
--- 36,45 ----
  #include "signames.h"
  #include "builtins/common.h"
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
  /* Flags which describe the current handling state of a signal. */
  #define SIG_INHERITED   0x0	/* Value inherited from parent. */
  #define SIG_TRAPPED     0x1	/* Currently trapped. */
***************
*** 514,519 ****
--- 518,545 ----
  /* Handle the calling of "trap 0".  The only sticky situation is when
     the command to be executed includes an "exit".  This is why we have
     to provide our own place for top_level to jump to. */
+ #if defined (__MSDOS__)
+ /* static variables wrapper */
+ int
+ dosutil_get_signal_modes (int sig)
+ {
+   if (sig < 0 || sig >= NSIG)
+     return -1;
+   return sigmodes[sig];
+ }
+ 
+ int
+ dosutil_set_signal_modes (int sig, int modes)
+ {
+   int oldmodes;
+   if (sig < 0 || sig >= NSIG)
+     return -1;
+   oldmodes = sigmodes[sig];
+   sigmodes[sig] = modes;
+   return oldmodes;
+ }
+ #endif
+ 
  int
  run_exit_trap ()
  {
***************
*** 564,569 ****
--- 590,599 ----
  {
    char *trap_command, *old_trap;
    int old_exit_value, old_line_number;
+ #if defined (__MSDOS__)
+   int old_subshell_exit_builtin;
+   extern int subshell_exit_builtin;
+ #endif
  
    /* Run the trap only if SIG is trapped and not ignored, and we are not
       currently executing in the trap handler. */
***************
*** 578,588 ****
--- 608,625 ----
  
        running_trap = sig + 1;
        old_exit_value = last_command_exit_value;
+ #if defined (__MSDOS__)
+       old_subshell_exit_builtin = subshell_exit_builtin; 
+       subshell_exit_builtin = 0;
+ #endif
        /* Need to copy the value of line_number because parse_and_execute
  	 resets it to 1, and the trap command might want it. */
        trap_line_number = line_number;
        parse_and_execute (trap_command, tag, SEVAL_NONINT|SEVAL_NOHIST);
        last_command_exit_value = old_exit_value;
+ #if defined (__MSDOS__)
+       subshell_exit_builtin = old_subshell_exit_builtin;
+ #endif
        running_trap = 0;
  
        sigmodes[sig] &= ~SIG_INPROGRESS;
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/trap.h bash-2.03/trap.h
*** bash203/trap.h	Fri Feb 21 11:32:28 1997
--- bash-2.03/trap.h	Fri Feb 19 17:42:12 1999
***************
*** 29,35 ****
--- 29,39 ----
  #endif /* SIG_DFL */
  
  #if !defined (NSIG)
+ #if defined (__DJGPP__) && defined (SIGMAX)
+ #define NSIG SIGMAX
+ #else
  #define NSIG 64
+ #endif /* !SIGMAX */
  #endif /* !NSIG */
  
  #define NO_SIG -1
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/variables.c bash-2.03/variables.c
*** bash203/variables.c	Tue Nov 10 13:29:44 1998
--- bash-2.03/variables.c	Tue Aug  3 11:19:14 1999
***************
*** 58,63 ****
--- 58,75 ----
  #  include <readline/history.h>
  #endif /* HISTORY */
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #if defined (__DJGPP__)
+ #define dup2 dosutil_dup2_wrapper
+ #endif
+ #endif
+ 
+ #if defined (USE_MULTIBYTE)
+ #include <mbctype.h>
+ #include <mbstring.h>
+ #endif
+ 
  /* Variables used here and defined in other files. */
  extern int posixly_correct;
  extern int variable_context, line_number;
***************
*** 221,228 ****
--- 233,250 ----
  #endif
        else
  	{
+ #ifdef att_unixypath
+ 	  int is_unixy_path = dosutil_import_unixy_pathvar (name, &string);
+ #endif
  	  temp_var = bind_variable (name, string);
  	  temp_var->attributes |= (att_exported | att_imported);
+ #ifdef att_unixypath
+ 	  if (is_unixy_path)
+ 	    {
+ 	      temp_var->attributes |= att_unixypath;
+ 	      free (string);
+ 	    }
+ #endif
  	  array_needs_making = 1;
  	}
  
***************
*** 245,250 ****
--- 267,275 ----
  	{
  	  temp_var = bind_variable ("PWD", temp_string);
  	  set_auto_export (temp_var);
+ #ifdef att_unixypath
+           temp_var->attributes |= att_unixypath;
+ #endif
  	  free (temp_string);
  	}
      }
***************
*** 254,259 ****
--- 279,287 ----
       Make a dummy invisible variable for OLDPWD, and mark it as exported. */
    temp_var = bind_variable ("OLDPWD", (char *)NULL);
    temp_var->attributes |= (att_exported | att_invisible);
+ #ifdef att_unixypath
+   temp_var->attributes |= att_unixypath;
+ #endif
  
    /* Set up initial value of $_ */
    temp_var = bind_variable ("_", dollar_vars[0]);
***************
*** 266,272 ****
--- 294,310 ----
    temp_var = set_if_not ("PATH", DEFAULT_PATH_VALUE);
    set_auto_export (temp_var);
  
+ #if defined (__MSDOS__)
+   temp_var = find_variable ("TERM");
+   if (!temp_var)
+     {
+       /* makes empty invisible variable */
+       temp_var = bind_variable ("TERM", (char *) NULL);
+       temp_var->attributes |= att_invisible;
+     }
+ #else
    temp_var = set_if_not ("TERM", "dumb");
+ #endif
    set_auto_export (temp_var);
  
  #if defined (qnx)
***************
*** 359,365 ****
--- 397,407 ----
       that we are remembering commands on the history list. */
    if (remember_on_history)
      {
+ #ifndef __MSDOS__
        name = bash_tilde_expand (posixly_correct ? "~/.sh_history" : "~/.bash_history");
+ #else
+       name = bash_tilde_expand (posixly_correct ? "~/_shhist" : "~/_bhist");
+ #endif
  
        set_if_not ("HISTFILE", name);
        free (name);
***************
*** 420,425 ****
--- 462,470 ----
    if (temp_var == 0)
      temp_var = bind_variable ("HOME", get_home_dir ());
    temp_var->attributes |= att_exported;
+ #ifdef __MSDOS__
+   temp_var->attributes |= att_unixypath;
+ #endif
  }
  
  /* Set $SHELL to the user's login shell if it is not already set.  Call
***************
*** 452,457 ****
--- 497,506 ----
      }
    else if (*shell_name == '/')
      name = savestring (shell_name);
+ #if defined (HAVE_DOS_STYLE_PATHNAMES)
+   else if (*shell_name && shell_name[1] == ':')
+     name = savestring (shell_name);
+ #endif
    else if (shell_name[0] == '.' && shell_name[1] == '/')
      {
        /* Fast path for common case. */
***************
*** 475,481 ****
--- 524,543 ----
  	{
  	  /* Try the current directory.  If there is not an executable
  	     there, just punt and use the login shell. */
+ #if defined (__MSDOS__)
+ 	  {
+ 	    char *fixp;
+ 	    
+ 	    /* for adding extention (dot + 3ext) */
+ 	    fixp = xmalloc (1 + strlen (shell_name) + 1 + 3);
+ 	    strcpy (fixp, shell_name);
+             dosutil_add_executable_suffix (fixp);
+ 	    s = file_status (fixp);
+ 	    free (fixp);
+ 	  }
+ #else
  	  s = file_status (shell_name);
+ #endif
  	  if (s & FS_EXECABLE)
  	    {
  	      tname = make_absolute (shell_name, get_string_value ("PWD"));
***************
*** 753,760 ****
--- 815,830 ----
    register SHELL_VAR *var;
  
    for (i = 0; list && (var = list[i]); i++)
+ #if defined (__MSDOS__)
+     {
+       QUIT;
+     if (!invisible_p (var))
+       print_assignment (var);
+     }
+ #else
      if (!invisible_p (var))
        print_assignment (var);
+ #endif
  }
  
  #if defined (NOTDEF)
***************
*** 1940,1946 ****
    return (entry);
  }
  
! #ifdef INCLUDE_UNUSED
  /* Copy VAR to a new data structure and return that structure. */
  SHELL_VAR *
  copy_variable (var)
--- 2010,2017 ----
    return (entry);
  }
  
! #if defined (__MSDOS__) || defined (INCLUDE_UNUSED)
! /*#ifdef INCLUDE_UNUSED*/
  /* Copy VAR to a new data structure and return that structure. */
  SHELL_VAR *
  copy_variable (var)
***************
*** 2193,2198 ****
--- 2264,2273 ----
  	  strcpy (p, var->name);
  	  p[name_len] = '=';
  	  strcpy (p + name_len + 1, value);
+ #if defined (__MSDOS__)
+ 	  if (unixypath_p (var))
+ 	    p = list[list_index] = dosutil_export_unixy_pathvar (p);
+ #endif
  	  list_index++;
  #if defined (ARRAY_VARS)
  	  if (array_p (var))
***************
*** 2439,2445 ****
      export_env[export_env_index++] = (do_alloc) ? savestring (envstr) : envstr; \
      export_env[export_env_index] = (char *)NULL; \
    } while (0)
- 
  #define ISFUNCTION(s, o) ((s[o + 1] == '(')  && (s[o + 2] == ')'))
  
  /* Add ASSIGN to EXPORT_ENV, or supercede a previous assignment in the
--- 2514,2519 ----
***************
*** 2467,2476 ****
--- 2541,2556 ----
  	{
  	  free (export_env[i]);
  	  export_env[i] = do_alloc ? savestring (assign) : assign;
+ #if defined (__MSDOS__) && 0
+ 	  export_env[i] = dosutil_fix_variable (export_env[i]);
+ #endif
  	  return (export_env);
  	}
      }
    add_to_export_env (assign, do_alloc);
+ #if 0
+   export_env[export_env_index-1] = dosutil_fix_variable (export_env[export_env_index-1]);
+ #endif
    return (export_env);
  }
  
***************
*** 2692,2697 ****
--- 2772,2785 ----
  
  #if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
    { "TZ", sv_tz },
+ #endif
+ 
+ #if defined (__MSDOS__)
+   { "PATH_EXPAND", sv_path_expand },
+   { "PATH_SEPARATOR", sv_path_separator },
+   { "PATH_SLASH", sv_path_slash },
+   { "SYSROOT", sv_sysroot },
+   { DOSUTIL_TEST_VAR_NAME, sv_test_finds_exe },
  #endif
  
    { (char *)0, (VFunction *)0 }
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/variables.h bash-2.03/variables.h
*** bash203/variables.h	Tue Nov 10 13:30:18 1998
--- bash-2.03/variables.h	Tue Aug  3 10:49:32 1999
***************
*** 45,50 ****
--- 45,53 ----
  #define att_imported  0x080	/* came from environment */
  #define att_local     0x100	/* variable is local to a function */
  #define att_tempvar   0x200	/* variable came from the temp environment */
+ #ifdef __MSDOS__
+ #define att_unixypath 0x400   /* variable is a Unixy path */
+ #endif
  
  #define exported_p(var)		((((var)->attributes) & (att_exported)))
  #define readonly_p(var)		((((var)->attributes) & (att_readonly)))
***************
*** 56,61 ****
--- 59,69 ----
  #define imported_p(var)         ((((var)->attributes) & (att_imported)))
  #define local_p(var)		((((var)->attributes) & (att_local)))
  #define tempvar_p(var)		((((var)->attributes) & (att_tempvar)))
+ #ifdef __MSDOS__
+ #define unixypath_p(var)	((((var)->attributes) & (att_unixypath)))
+ #else
+ #define unixypath_p(var)	0
+ #endif
  
  #define value_cell(var) ((var)->value)
  #define function_cell(var) (COMMAND *)((var)->value)
diff -c3 -x configure -x Makefile -x termcap.info --recursive bash203/version.c bash-2.03/version.c
*** bash203/version.c	Thu Feb  4 15:13:06 1999
--- bash-2.03/version.c	Fri Feb 19 17:42:12 1999
***************
*** 22,27 ****
--- 22,31 ----
  
  #include "version.h"
  
+ #if defined (__MSDOS__)
+ #include "dosutil.h"
+ #endif
+ 
  extern char *shell_name;
  
  /* Defines from version.h */
***************
*** 65,71 ****
--- 69,80 ----
  show_shell_version (extended)
       int extended;
  {
+ #if defined (__MSDOS__)
+   printf ("GNU bash, version %s (%s) %s\n", shell_version_string (), MACHTYPE,
+ 	  dosutil_version_string ());
+ #else
    printf ("GNU bash, version %s (%s)\n", shell_version_string (), MACHTYPE);
+ #endif
    if (extended)
      printf ("Copyright 1998 Free Software Foundation, Inc.\n");
  }
