diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 52fd39da841..b077bf8b8ee 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -1347,8 +1347,12 @@ get_set_pwd(void) } if (!fgets(pwdbuf, sizeof(pwdbuf), pwf)) { - fprintf(stderr, _("%s: could not read password from file \"%s\": %s\n"), - progname, pwfilename, strerror(errno)); + if (ferror(pwf)) + fprintf(stderr, _("%s: could not read password from file \"%s\": %s\n"), + progname, pwfilename, strerror(errno)); + else + fprintf(stderr, _("%s: password file \"%s\" is empty\n"), + progname, pwfilename); exit_nicely(); } fclose(pwf);