Re: [patch] avoid invoking commands with empty argument

2003-02-11 Thread Pavel Roskin
Hello, Adam!

On Tue, 11 Feb 2003, Adam Byrtek / alpha wrote:

 mc passes an empty argument () to the EDITOR when creating new file
 (with F14). It makes vim to list the current dircetory. The nvi doesn't
 create temporary file, so write command won't work, however if you call
 nvi without any argument it creates a temp file to save the data in. The
 same problem occur with some other editors (jed to name one)

What is passed to my_system() - NULL or empty string?  If it's an empty
string, where does it come from?  It's trivial for me to run it in the
debugger, but I assume you did it already.

What happens if EXECUTE_AS_SHELL is set, but command is NULL?  I
understand that the shell won't be executed at all.  This is how it's
called from view_other_cmd() if output_starts_shell is set.

P.S. Empty string comes from edit_cmd_new().  It should be fine to use
NULL if we take care not to run vfs_file_is_local() on NULL in
execute_with_vfs_arg().

How do you like following patch?  Is there any other reason (apart from
running the editor) for replacing  with NULL in my_system()?

===
--- cmd.c
+++ cmd.c
@@ -97,7 +97,7 @@ execute_with_vfs_arg (const char *comman
 time_t mtime;

 /* Simplest case, this file is local */
-if (vfs_file_is_local (filename)) {
+if (!filename || vfs_file_is_local (filename)) {
execute_internal (command, filename);
return;
 }
@@ -348,7 +348,7 @@ edit_cmd (void)
 void
 edit_cmd_new (void)
 {
-do_edit ();
+do_edit (NULL);
 }

 /* Invoked by F5.  Copy, default to the other panel.  */
===

-- 
Regards,
Pavel Roskin
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel



Re: [patch] avoid invoking commands with empty argument

2003-02-11 Thread Adam Byrtek / alpha
On Tue, Feb 11, 2003 at 12:07:50PM -0500, Pavel Roskin wrote:
 P.S. Empty string comes from edit_cmd_new().  It should be fine to use
 NULL if we take care not to run vfs_file_is_local() on NULL in
 execute_with_vfs_arg().

Your patch is better, it sorts things on higher level. I wanted to be
sure any other empty string will be converted to NULL in my_system(),
but I guess this is not necessary, and could even break things.

 What happens if EXECUTE_AS_SHELL is set, but command is NULL?  I
 understand that the shell won't be executed at all.  This is how it's
 called from view_other_cmd() if output_starts_shell is set.

Strange, this should never happen! 
This line:

if (flags  EXECUTE_AS_SHELL)
execl (shell, shell, -c, command, NULL);

Invokes just a 'shell -c' when no command is given. I've just tested.
I've set show_output_starts_shell=1 and started cvs mc with 'mc -u',
and after Ctrl-O I saw only this before mc returned to panels:

 Type exit' to return to the Midnight Commander
   
 zsh: string expected after -c

Regards 

-- 

  _.|._ |_  _.: Adam Byrtek, alpha@(irc.pl|debian.org)
 (_|||_)| |(_|: gg 1802819, pgp 0xB25952C0
 |: jid alpha.pl(at)jabber.org
___
Mc-devel mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/mc-devel