|
3 | 3 | * |
4 | 4 | * Copyright (c) 2000-2010, PostgreSQL Global Development Group |
5 | 5 | * |
6 | | - * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.163 2010/03/06 15:28:09 mha Exp $ |
| 6 | + * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.164 2010/03/07 17:02:34 mha Exp $ |
7 | 7 | */ |
8 | 8 | #include"postgres_fe.h" |
9 | 9 |
|
@@ -68,12 +68,11 @@ struct adhoc_opts |
68 | 68 | boolno_readline; |
69 | 69 | boolno_psqlrc; |
70 | 70 | boolsingle_txn; |
71 | | -char*psqlrc; |
72 | 71 | }; |
73 | 72 |
|
74 | 73 | staticvoidparse_psql_options(intargc,char*argv[], |
75 | 74 | structadhoc_opts*options); |
76 | | -staticvoidprocess_psqlrc(char*argv0,structadhoc_opts*options); |
| 75 | +staticvoidprocess_psqlrc(char*argv0); |
77 | 76 | staticvoidprocess_psqlrc_file(char*filename); |
78 | 77 | staticvoidshowVersion(void); |
79 | 78 | staticvoidEstablishVariableSpace(void); |
@@ -248,7 +247,8 @@ main(int argc, char *argv[]) |
248 | 247 | */ |
249 | 248 | if (options.action==ACT_FILE) |
250 | 249 | { |
251 | | -process_psqlrc(argv[0],&options); |
| 250 | +if (!options.no_psqlrc) |
| 251 | +process_psqlrc(argv[0]); |
252 | 252 |
|
253 | 253 | successResult=process_file(options.action_string,options.single_txn); |
254 | 254 | } |
@@ -291,7 +291,8 @@ main(int argc, char *argv[]) |
291 | 291 | */ |
292 | 292 | else |
293 | 293 | { |
294 | | -process_psqlrc(argv[0],&options); |
| 294 | +if (!options.no_psqlrc) |
| 295 | +process_psqlrc(argv[0]); |
295 | 296 |
|
296 | 297 | connection_warnings(true); |
297 | 298 | if (!pset.quiet&& !pset.notty) |
@@ -354,7 +355,6 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) |
354 | 355 | {"password",no_argument,NULL,'W'}, |
355 | 356 | {"expanded",no_argument,NULL,'x'}, |
356 | 357 | {"no-psqlrc",no_argument,NULL,'X'}, |
357 | | -{"psqlrc",required_argument,NULL,1}, |
358 | 358 | {"help",no_argument,NULL,'?'}, |
359 | 359 | {NULL,0,NULL,0} |
360 | 360 | }; |
@@ -515,9 +515,6 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) |
515 | 515 | case'X': |
516 | 516 | options->no_psqlrc= true; |
517 | 517 | break; |
518 | | -case1: |
519 | | -options->psqlrc=pg_strdup(optarg); |
520 | | -break; |
521 | 518 | case'1': |
522 | 519 | options->single_txn= true; |
523 | 520 | break; |
@@ -566,27 +563,20 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) |
566 | 563 | * Load .psqlrc file, if found. |
567 | 564 | */ |
568 | 565 | staticvoid |
569 | | -process_psqlrc(char*argv0,structadhoc_opts*options) |
| 566 | +process_psqlrc(char*argv0) |
570 | 567 | { |
571 | 568 | charhome[MAXPGPATH]; |
572 | 569 | charrc_file[MAXPGPATH]; |
573 | 570 | charmy_exec_path[MAXPGPATH]; |
574 | 571 | charetc_path[MAXPGPATH]; |
575 | 572 |
|
576 | | -if (options->no_psqlrc) |
577 | | -return; |
578 | | - |
579 | 573 | find_my_exec(argv0,my_exec_path); |
580 | 574 | get_etc_path(my_exec_path,etc_path); |
581 | 575 |
|
582 | 576 | snprintf(rc_file,MAXPGPATH,"%s/%s",etc_path,SYSPSQLRC); |
583 | 577 | process_psqlrc_file(rc_file); |
584 | 578 |
|
585 | | -if (options->psqlrc) |
586 | | -{ |
587 | | -process_psqlrc_file(options->psqlrc); |
588 | | -} |
589 | | -elseif (get_home_path(home)) |
| 579 | +if (get_home_path(home)) |
590 | 580 | { |
591 | 581 | snprintf(rc_file,MAXPGPATH,"%s/%s",home,PSQLRC); |
592 | 582 | process_psqlrc_file(rc_file); |
|