psql's EDITOR behavior on Windows - Mailing list pgsql-hackers

From Pavlo Golub
Subject psql's EDITOR behavior on Windows
Date
Msg-id CAK7ymcLwDia8deBCX+oLjSbHrJM32LuvomXq7i6uJ3g7z-MhAw@mail.gmail.com
Whole thread Raw
Responses Re: psql's EDITOR behavior on Windows  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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);
    ...
}



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Unix-domain socket support on Windows
Next
From: Tom Lane
Date:
Subject: Re: Read Uncommitted