     (if (eq (elt str last) ?/)
 	(substring str 0 last)
       str)))
+
+(defun replace-backslash-by-slash (str)
+  (substitute ?/ ?\\ str))
 
 ;; The following is almost the same as the above. The difference is that
 ;; in the following we execute a Specware application (rather than run Lisp

		    )
    (when in-current-dir?
      (sw:eval-in-lisp (format "(setf (sys:getenv \"SWPATH\") %S)"
			       (concat root-dir ":/")))
      (sw:eval-in-lisp (format "(setf (sys:getenv \"SPECWARE4\") %S)" root-dir)))
    ))


    (unless (inferior-lisp-running-p)
      (sleep-for 1))
    (sw:eval-in-lisp (format "(setf (sys:getenv \"SWPATH\") %S)"
			     (concat (replace-backslash-by-slash root-dir) ":/")))
    (sw:eval-in-lisp (format "(setf (sys:getenv \"SPECWARE4\") %S)" root-dir))
    (sw:eval-in-lisp (format "(top-level::do-command :cd %S)" dir))
    (sw:eval-in-lisp "(load \"Specware4.lisp\")")
