diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 8421ad0086..aa000735dc 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -2062,14 +2062,17 @@ process_file(char *filename, bool single_txn, bool use_relative_path) } fd = fopen(filename, PG_BINARY_R); + + if (!fd) + { + psql_error("%s: %s\n", filename, strerror(errno)); + return EXIT_FAILURE; + } } else - fd = stdin; - - if (!fd) { - psql_error("%s: %s\n", filename, strerror(errno)); - return EXIT_FAILURE; + fd = stdin; + filename = ""; /* for future error messages */ } oldfilename = pset.inputfile; diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index aff57728a2..166c227d6b 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -313,8 +313,6 @@ main(int argc, char *argv[]) printf(_("Type \"help\" for help.\n\n")); if (!pset.notty) initializeInput(options.no_readline ? 0 : 1); - if (options.action_string) /* -f - was used */ - pset.inputfile = ""; successResult = MainLoop(stdin); }