Redirecting stderr in fish



Hello!

I wasn't sure whether to apply the patch by Rich Roth that would redirect
stderr of the "ls" command to /dev/null. I hoped to do it in a more
generic way, by redirecting the output of ssh.

However, it turns out that both should be done. When we have
OpenSSH_2.5.2p2 on the client and OpenSSH_2.3.0p1 on the server (just the
first combination I happened to test), the remote stdout goes to stdout.

However, if mc is run under Electric Fence, the initial message from ssh
goes to stderr and confuses mc. It's also possible that in some
client-server combinations the remote stderr goes to stderr of ssh (I
remember seeing that but I cannot reproduce it now).

Another source of unwanted messages in "logout" - it says "bash: logout:
not login shell: use `exit'", and this is true.

I've just aplied this patch.

___________________________________
--- ChangeLog
+++ ChangeLog
@@ -1 +1,10 @@
+2001-05-22  Pavel Roskin  <proski gnu org>
+
+	* fish.c (free_archive): Use `exit' instead of `logout' - the
+	later fails under non-login shells.
+	(pipeopen): Redirect stderr of ssh to /dev/null.
+	From Rich Roth:
+	(dir_load): Redirect stderr of ls to /dev/null.
+	(linear_start): Likewise.
+
 2001-05-22  Andrew V. Samoilov  <sav bcs zp ua>
--- fish.c
+++ fish.c
@@ -138,7 +138,7 @@ free_archive (vfs *me, vfs_s_super *supe
 {
     if ((SUP.sockw != -1) || (SUP.sockr != -1)){
 	print_vfs_message (_("fish: Disconnecting from %s"), super->name?super->name:"???");
-	command(me, super, NONE, "#BYE\nlogout\n");
+	command(me, super, NONE, "#BYE\nexit\n");
 	close(SUP.sockw);
 	close(SUP.sockr);
 	SUP.sockw = SUP.sockr = -1;
@@ -172,7 +172,8 @@ pipeopen(vfs_s_super *super, char *path,
 	close(fileset1[0]); close(fileset1[1]);
 	close(1); close(2);
 	dup(fileset2[1]);
-	dup(fileset2[1]);
+	/* stderr to /dev/null */
+	open ("/dev/null", O_WRONLY);
 	close(fileset2[0]); close(fileset2[1]);
 	execvp(path, argv);
 	vfs_die("Exec failed.");
@@ -358,12 +359,12 @@ dir_load(vfs *me, vfs_s_inode *dir, char

     command(me, super, NONE,
 	    "#LIST /%s\n"
-	    "ls -lLa \"/%s\" | grep '^[^cbt]' | (\n"
+	    "ls -lLa \"/%s\" 2>/dev/null | grep '^[^cbt]' | (\n"
 	      "while read p x u g s m d y n; do\n"
 	        "echo \"P$p $u.$g\nS$s\nd$m $d $y\n:$n\n\"\n"
 	      "done\n"
 	    ")\n"
-	    "ls -lLa \"/%s\" | grep '^[cb]' | (\n"
+	    "ls -lLa \"/%s\" 2>/dev/null | grep '^[cb]' | (\n"
 	      "while read p x u g a i m d y n; do\n"
 	        "echo \"P$p $u.$g\nE$a$i\nd$m $d $y\n:$n\n\"\n"
 	      "done\n"
@@ -535,7 +536,7 @@ static int linear_start(vfs *me, vfs_s_f
 	return 0;
     offset = command(me, FH_SUPER, WANT_STRING,
 		"#RETR /%s\n"
-		"ls -l \"/%s\" | (\n"
+		"ls -l \"/%s\" 2>/dev/null | (\n"
 		  "read var1 var2 var3 var4 var5 var6\n"
 		  "echo \"$var5\"\n"
 		")\n"
___________________________________

Regards,
Pavel Roskin





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]