summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile5
-rw-r--r--src/remote.ml6
-rw-r--r--src/ubase/util.ml24
-rw-r--r--src/ubase/util.mli2
-rw-r--r--src/uitext.ml20
5 files changed, 39 insertions, 18 deletions
diff --git a/src/Makefile b/src/Makefile
index e32ad6d..851838f 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -79,7 +79,9 @@ installtext:
text:
$(MAKE) -C .. text
-doinstall: $(NAME)$(EXEC_EXT)
+# Note that this is not needed (and doesn't work) for the OSX GUI version.
+# Just copy $(UIMACDIR)/build/Default/Unison.app to where you want it.
+doinstall: buildexecutable
@if [ ! $(NAME) ]; then \
echo "makefile variable NAME not bound"; \
exit 1 \
@@ -88,7 +90,6 @@ doinstall: $(NAME)$(EXEC_EXT)
cp $(NAME)$(EXEC_EXT) $(INSTALLDIR)
cp $(NAME)$(EXEC_EXT) $(INSTALLDIR)$(NAME)-$(MAJORVERSION)$(EXEC_EXT)
-
######################################################################
# Demo
diff --git a/src/remote.ml b/src/remote.ml
index ddca0d7..77062eb 100644
--- a/src/remote.ml
+++ b/src/remote.ml
@@ -488,7 +488,8 @@ let rshargs =
("The string value of this preference will be passed as additional "
^ "arguments (besides the host name and the name of the Unison "
^ "executable on the remote system) to the \\verb|rsh| "
- ^ "command used to invoke the remote server. "
+ ^ "command used to invoke the remote server. The backslash is an "
+ ^ "escape character."
)
let sshargs =
@@ -497,7 +498,8 @@ let sshargs =
("The string value of this preference will be passed as additional "
^ "arguments (besides the host name and the name of the Unison "
^ "executable on the remote system) to the \\verb|ssh| "
- ^ "command used to invoke the remote server. "
+ ^ "command used to invoke the remote server. The backslash is an "
+ ^ "escape character."
)
let serverCmd =
diff --git a/src/ubase/util.ml b/src/ubase/util.ml
index c91acef..9f4fe66 100644
--- a/src/ubase/util.ml
+++ b/src/ubase/util.ml
@@ -401,15 +401,25 @@ let trimWhitespace s =
in
loop 0 (l-1)
-let splitIntoWords (s:string) (c:char) =
- let rec inword acc start pos =
- if pos >= String.length(s) || s.[pos] = c then
- betweenwords ((String.sub s start (pos-start)) :: acc) pos
- else inword acc start (pos+1)
+let splitIntoWords ?esc:(e='\\') (s:string) (c:char) =
+ let rec inword acc eacc start pos =
+ if pos >= String.length s || s.[pos] = c then
+ let word =
+ String.concat "" (Safelist.rev (String.sub s start (pos-start)::eacc)) in
+ betweenwords (word::acc) pos
+ else if s.[pos] = e then inescape acc eacc start pos
+ else inword acc eacc start (pos+1)
+ and inescape acc eacc start pos =
+ let eword = String.sub s start (pos-start) in
+ if pos+1 >= String.length s
+ then inword acc (eword::eacc) (pos+1) (pos+1) (* ignore final esc *)
+ else (* take any following char *)
+ let echar = String.make 1 (String.get s (pos+1)) in
+ inword acc (echar::eword::eacc) (pos+2) (pos+2)
and betweenwords acc pos =
- if pos >= (String.length s) then (Safelist.rev acc)
+ if pos >= String.length s then (Safelist.rev acc)
else if s.[pos]=c then betweenwords acc (pos+1)
- else inword acc pos pos
+ else inword acc [] pos pos
in betweenwords [] 0
let rec splitIntoWordsByString s sep =
diff --git a/src/ubase/util.mli b/src/ubase/util.mli
index d4bd8f7..d7409c8 100644
--- a/src/ubase/util.mli
+++ b/src/ubase/util.mli
@@ -55,7 +55,7 @@ val replacesubstrings : string -> (string * string) list -> string
val concatmap : string -> ('a -> string) -> 'a list -> string
val removeTrailingCR : string -> string
val trimWhitespace : string -> string
-val splitIntoWords : string -> char -> string list
+val splitIntoWords : ?esc:char -> string -> char -> string list
val splitIntoWordsByString : string -> string -> string list
val padto : int -> string -> string
diff --git a/src/uitext.ml b/src/uitext.ml
index 3706923..25891e9 100644
--- a/src/uitext.ml
+++ b/src/uitext.ml
@@ -177,7 +177,19 @@ let rec selectAction batch actions tryagain =
doAction (match batch with
None ->
summarizeChoices();
- getInput ()
+ let handleExn s =
+ (* Make sure that the error messages start on their own lines and not
+ * after the prompt. *)
+ alwaysDisplay "\n";
+ raise (Util.Fatal ("Failure reading from the standard input ("^s^")\n"))
+ in
+ begin try getInput () with
+ (* Simply print a slightly more informative message than the exception
+ * itself (e.g. "Uncaught unix error: read failed: Resource temporarily
+ * unavailable" or "Uncaught exception End_of_file"). *)
+ End_of_file -> handleExn "End of file"
+ | Unix.Unix_error (err, _, _) -> handleExn (Unix.error_message err)
+ end
| Some i -> i)
let alwaysDisplayErrors prefix l =
@@ -824,11 +836,7 @@ let handleException e =
restoreTerminal();
let msg = Uicommon.exn2string e in
Trace.log (msg ^ "\n");
- if not !Trace.sendLogMsgsToStderr then begin
- alwaysDisplay "\n";
- alwaysDisplay msg;
- alwaysDisplay "\n";
- end
+ if not !Trace.sendLogMsgsToStderr then alwaysDisplay ("\n" ^ msg ^ "\n")
let rec start interface =
if interface <> Uicommon.Text then