psql's EDITOR behavior on Windows

From: Pavlo Golub <pavlo(dot)golub(at)cybertec(dot)at>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: psql's EDITOR behavior on Windows
Date: 2019-12-18 13:56:49
Message-ID: CAK7ymcLwDia8deBCX+oLjSbHrJM32LuvomXq7i6uJ3g7z-MhAw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello.

I cannot find the reason why EDITOR value on Windows is quoted. It
should not be. One may force quote env var if he wants to.

Right now, for example, one cannot use sublime, since to use it in a
proper way you should
SET EDITOR="C:\Program Files\Sublime\subl.exe" --wait

The problem can be solved by introducing PSQL_EDITOR_ARGS env var, but
just not quoting EDITOR command on Windows will work too.

psql\command.c:

static bool
editFile(const char *fname, int lineno)
{
...

/*
* On Unix the EDITOR value should *not* be quoted, since it might include
* switches, eg, EDITOR="pico -t"; it's up to the user to put quotes in it
* if necessary. But this policy is not very workable on Windows, due to
* severe brain damage in their command shell plus the fact that standard
* program paths include spaces.
*/
...
if (lineno > 0)
sys = psprintf("\"%s\" %s%d \"%s\"",
editorName, editor_lineno_arg, lineno, fname);
else
sys = psprintf("\"%s\" \"%s\"",
editorName, fname);
...
}

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-12-18 14:06:04 Re: Read Uncommitted
Previous Message Peter Eisentraut 2019-12-18 13:52:15 Re: Unix-domain socket support on Windows