Re: about EDITOR_LINENUMBER_SWITCH
От | Bruce Momjian |
---|---|
Тема | Re: about EDITOR_LINENUMBER_SWITCH |
Дата | |
Msg-id | 201110141505.p9EF52D00757@momjian.us обсуждение исходный текст |
Ответ на | Re: about EDITOR_LINENUMBER_SWITCH (Robert Haas <robertmhaas@gmail.com>) |
Список | pgsql-hackers |
Robert Haas wrote: > On Thu, Oct 13, 2011 at 11:31 AM, Bruce Momjian <bruce@momjian.us> wrote: > > Alvaro Herrera wrote: > >> Excerpts from Tom Lane's message of mi? may 25 16:07:55 -0400 2011: > >> > Alvaro Herrera <alvherre@commandprompt.com> writes: > >> > > Excerpts from Tom Lane's message of mar may 24 17:11:17 -0400 2011: > >> > >> Right. ?It would also increase the cognitive load on the user to have > >> > >> to remember the command-line go-to-line-number switch for his editor. > >> > >> So I don't particularly want to redesign this feature. ?However, I can > >> > >> see the possible value of letting EDITOR_LINENUMBER_SWITCH be set from > >> > >> the same place that you set EDITOR, which would suggest that we allow > >> > >> the value to come from an environment variable. ?I'm not sure whether > >> > >> there is merit in allowing both that source and ~/.psqlrc, though > >> > >> possibly for Windows users it might be easier if ~/.psqlrc worked. > >> > > >> > > If we're going to increase the number of options in .psqlrc that do not > >> > > work with older psql versions, can I please have .psqlrc-MAJORVERSION or > >> > > some such? ?Having 8.3's psql complain all the time because it doesn't > >> > > understand "linestyle" is annoying. > >> > > >> > 1. I thought we already did have that. > >> > >> Oh, true, we have that, though it's not very usable because you have to > >> rename the file from .psqlrc-9.0.3 to .psqlrc-9.0.4 when you upgrade, > >> which is kinda silly. > > > > True. ?We don't add configuration changes in minor versions so having > > minor-version granularity makes no sense. > > > > The attached patch changes this to use the _major_ version number for > > psql rc files. ?Does this have to be backward-compatible? ?Should I > > check for minor and major matches? ?That is going to be confusing to > > document. > > Checking for a minor match and then a major match seems sensible. Done, and documented in the attached patch. -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml new file mode 100644 index 662eab7..4eefe3b *** a/doc/src/sgml/ref/psql-ref.sgml --- b/doc/src/sgml/ref/psql-ref.sgml *************** PSQL_EDITOR_LINENUMBER_ARG='--line ' *** 3332,3339 **** Both the system-wide <filename>psqlrc</filename> file and the user's <filename>~/.psqlrc</filename> file can be made version-specific by appending a dash and the <productname>PostgreSQL</productname> ! release number, for example <filename>~/.psqlrc-&version;</filename>. ! A matching version-specific file will be read in preference to a non-version-specific file. </para> </listitem> --- 3332,3341 ---- Both the system-wide <filename>psqlrc</filename> file and the user's <filename>~/.psqlrc</filename> file can be made version-specific by appending a dash and the <productname>PostgreSQL</productname> ! major or minor release number, for example ! <filename>~/.psqlrc-9.2</filename> or ! <filename>~/.psqlrc-9.2.5</filename>. The most specific ! version-matching file will be read in preference to a non-version-specific file. </para> </listitem> diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c new file mode 100644 index 3c17eec..71829eb *** a/src/bin/psql/startup.c --- b/src/bin/psql/startup.c *************** process_psqlrc(char *argv0) *** 594,613 **** static void process_psqlrc_file(char *filename) { ! char *psqlrc; #if defined(WIN32) && (!defined(__MINGW32__)) #define R_OK 4 #endif ! psqlrc = pg_malloc(strlen(filename) + 1 + strlen(PG_VERSION) + 1); ! sprintf(psqlrc, "%s-%s", filename, PG_VERSION); ! if (access(psqlrc, R_OK) == 0) ! (void) process_file(psqlrc, false, false); else if (access(filename, R_OK) == 0) (void) process_file(filename, false, false); ! free(psqlrc); } --- 594,620 ---- static void process_psqlrc_file(char *filename) { ! char *psqlrc_minor, *psqlrc_major; #if defined(WIN32) && (!defined(__MINGW32__)) #define R_OK 4 #endif ! psqlrc_minor = pg_malloc(strlen(filename) + 1 + strlen(PG_VERSION) + 1); ! sprintf(psqlrc_minor, "%s-%s", filename, PG_VERSION); ! psqlrc_major = pg_malloc(strlen(filename) + 1 + strlen(PG_MAJORVERSION) + 1); ! sprintf(psqlrc_major, "%s-%s", filename, PG_MAJORVERSION); ! /* check for minor version first, then major, then no version */ ! if (access(psqlrc_minor, R_OK) == 0) ! (void) process_file(psqlrc_minor, false, false); ! else if (access(psqlrc_major, R_OK) == 0) ! (void) process_file(psqlrc_major, false, false); else if (access(filename, R_OK) == 0) (void) process_file(filename, false, false); ! ! free(psqlrc_minor); ! free(psqlrc_major); }
В списке pgsql-hackers по дате отправления: