--- ./os2/OS2/REXX/REXX.xs-pre	Mon Nov 18 21:09:12 2002
+++ ./os2/OS2/REXX/REXX.xs	Sun Nov 24 15:57:26 2002
@@ -72,7 +72,8 @@ exec_in_REXX_with(pTHX_ char *cmd, int c
     LONG rc;
     SV *res;
     char *subs = 0;
-    int n = c;
+    int n = c, have_nl = 0;
+    char *ocmd = cmd, *s, *t;
 
     incompartment++;
 
@@ -84,6 +85,23 @@ exec_in_REXX_with(pTHX_ char *cmd, int c
 	    subs[n] = 1;
     }
 
+    s = cmd;
+    while (*s) {
+	if (*s == '\n') {		/* Is not preceeded by \r! */
+	    New(728, cmd, 2*strlen(cmd)+1, char);
+	    s = ocmd;
+	    t = cmd;
+	    while (*s) {
+		if (*s == '\n')
+		    *t++ = '\r';
+		*t++ = *s++;
+	    }
+	    *t = 0;
+	    break;
+	} else if (*s == '\r')
+	    s++;
+	s++;
+    }
     MAKERXSTRING(args[0], NULL, 0);
     MAKERXSTRING(inst[0], cmd,  strlen(cmd));
     MAKERXSTRING(inst[1], NULL, 0);
@@ -105,6 +123,8 @@ exec_in_REXX_with(pTHX_ char *cmd, int c
 	    pRexxDeregisterFunction(handlerNames[n]);
     if (c)
 	Safefree(subs);
+    if (cmd != ocmd)
+	Safefree(cmd);
 #if 0					/* Do we want to restore these? */
     DosFreeModule(hRexxAPI);
     DosFreeModule(hRexx);
