Merge some changes from 1.0.4. Very odd.
[sw-tools] / src / sw_rsh.c
index 45815f8..e054351 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: sw_rsh.c,v 1.8 2004/04/08 01:52:19 mdw Exp $
+ * $Id$
  *
  * Run remote commands
  *
@@ -313,7 +313,7 @@ void swwait(sw_remote *r, int status)
 void swvprintf(sw_remote *r, const char *format, va_list ap)
 {
   dstr d = DSTR_INIT;
-  dstr_vputf(&d, format, ap);
+  dstr_vputf(&d, format, &ap);
   pksend(r, PKTYPE_DATA, d.buf, d.len);
   dstr_destroy(&d);
 }
@@ -356,7 +356,7 @@ void swdie(sw_remote *r, int status, const char *format, ...)
 
   va_start(ap, format);
   dstr_putf(&d, "%s [remote]: ", QUIS);
-  dstr_vputf(&d, format, ap);
+  dstr_vputf(&d, format, &ap);
   dstr_putc(&d, '\n');
   dstr_putz(&d);
   va_end(ap);
@@ -396,7 +396,7 @@ static void remote(sw_remote *r, const char *cmd, char *argv[], char *env[])
     sym_table t;
     sym_create(&t);
     env_import(&t, env);
-    if (env != environ) {
+    if (env[0] && env != environ) {
       free(env);
       env_import(&t, environ);
     }
@@ -538,7 +538,15 @@ void swrsh_remote(const char *cmd)
   r.fdin = 0;
   r.fdout = 1;
 
- /* --- Read packets from the remote host --- */
+  /* --- Object if stdin is a terminal --- */
+
+  if (isatty(STDIN_FILENO)) {
+    die(EXIT_FAILURE,
+       "don't use the `--remote' option unless "
+       "you know what you're doing.");
+  }
+
+  /* --- Read packets from the remote host --- */
 
   for (;;) {
     int t = pkrecv(&r);