Re: psql \e broken again - Mailing list pgsql-hackers

From Kevin Brown
Subject Re: psql \e broken again
Date
Msg-id 20041116105154.GB16280@filer
Whole thread Raw
In response to Re: psql \e broken again  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:
> "Magnus Hagander" <mha@sollentuna.net> writes:
> >> Agreed, no quotes on Unix.  I'm just wondering what to do 
> >> on Windows.
> 
> > I don't think I've seen a single windows program that uses the EDITOR
> > variable. There are some ported unix tools, but that's it. Native
> > windows program will have a per-program setting for this. The system
> > default is picked based on file extension. So I doubt it will break a
> > lot of things.
> 
> So are you in favor of not quoting at all --- ie, reverting to the Unix
> behavior?  I'm pretty sure that psql got changed because someone
> complained, so it seems like we'd be going in circles if we just do that
> and don't have any special behavior at all on Windows.

You probably already know this but others on the list may not, so...

The behavior of EDITOR under Unix comes about as a result of how it's
invoked -- usually via the system() library call, which invokes a
shell to parse the command.  The fact that spaces in EDITOR's value
are treated as argument delimeters instead of part of the path of the
editor itself is a direct result of how the shell interprets the
command string.

It almost certainly doesn't make sense to retain those semantics under
Windows, because to achieve real equivalence we would have to expand
other shell metacharacters ourselves.

Since Windows generally doesn't even make use of EDITOR as such, it
probably makes the most sense for \e on that platform to save the edit
buffer to a .txt file and "execute" it -- Windows will then invoke
whichever editor is associated with text files (Notepad by default).
It would have to be invoked in such a way that psql could wait for it
to complete, of course.

I suppose it might be nice to be able to override that, and do
something else if EDITOR is defined.  In that event it's probably
safer to avoid parsing EDITOR and instead have it just refer to the
full path to the program to be used.  Someone who is savvy enough to
define EDITOR is also savvy enough to throw together a simple batch
file which invokes his real editor with whatever options he wants.  It
seems to me that being able to properly specify the path of the
program to use with a minimum of fuss (hence no strange quoting
conventions) takes precedence.


-- 
Kevin Brown                          kevin@sysexperts.com


pgsql-hackers by date:

Previous
From: Neil Conway
Date:
Subject: Re: postmaster segfaults with HUGE table
Next
From: "Zeugswetter Andreas DAZ SD"
Date:
Subject: Re: psql \e broken again