@@ -139,6 +139,7 @@ static const char *authmethodhost = NULL;
139139static const char * authmethodlocal = NULL ;
140140static bool debug = false;
141141static bool noclean = false;
142+ static bool noinstructions = false;
142143static bool do_sync = true;
143144static bool sync_only = false;
144145static bool show_setting = false;
@@ -2294,6 +2295,7 @@ usage(const char *progname)
22942295 printf (_ (" -L DIRECTORY where to find the input files\n" ));
22952296 printf (_ (" -n, --no-clean do not clean up after errors\n" ));
22962297 printf (_ (" -N, --no-sync do not wait for changes to be written safely to disk\n" ));
2298+ printf (_ (" --no-instructions do not print instructions for next steps\n" ));
22972299 printf (_ (" -s, --show show internal settings\n" ));
22982300 printf (_ (" -S, --sync-only only sync data directory\n" ));
22992301 printf (_ ("\nOther options:\n" ));
@@ -2955,6 +2957,7 @@ main(int argc, char *argv[])
29552957 {"no-clean" , no_argument , NULL , 'n' },
29562958 {"nosync" , no_argument , NULL , 'N' }, /* for backwards compatibility */
29572959 {"no-sync" , no_argument , NULL , 'N' },
2960+ {"no-instructions" , no_argument , NULL , 13 },
29582961 {"sync-only" , no_argument , NULL , 'S' },
29592962 {"waldir" , required_argument , NULL , 'X' },
29602963 {"wal-segsize" , required_argument , NULL , 12 },
@@ -3095,6 +3098,9 @@ main(int argc, char *argv[])
30953098 case 12 :
30963099 str_wal_segment_size_mb = pg_strdup (optarg );
30973100 break ;
3101+ case 13 :
3102+ noinstructions = true;
3103+ break ;
30983104 case 'g' :
30993105 SetDataDirectoryCreatePerm (PG_DIR_MODE_GROUP );
31003106 break ;
@@ -3245,34 +3251,40 @@ main(int argc, char *argv[])
32453251 "--auth-local and --auth-host, the next time you run initdb.\n" ));
32463252 }
32473253
3248- /*
3249- * Build up a shell command to tell the user how to start the server
3250- */
3251- start_db_cmd = createPQExpBuffer ();
3254+ if (!noinstructions )
3255+ {
3256+ /*
3257+ * Build up a shell command to tell the user how to start the server
3258+ */
3259+ start_db_cmd = createPQExpBuffer ();
3260+
3261+ /* Get directory specification used to start initdb ... */
3262+ strlcpy (pg_ctl_path , argv [0 ], sizeof (pg_ctl_path ));
3263+ canonicalize_path (pg_ctl_path );
3264+ get_parent_directory (pg_ctl_path );
3265+ /* ... and tag on pg_ctl instead */
3266+ join_path_components (pg_ctl_path , pg_ctl_path , "pg_ctl" );
32523267
3253- /* Get directory specification used to start initdb ... */
3254- strlcpy (pg_ctl_path , argv [0 ], sizeof (pg_ctl_path ));
3255- canonicalize_path (pg_ctl_path );
3256- get_parent_directory (pg_ctl_path );
3257- /* ... and tag on pg_ctl instead */
3258- join_path_components (pg_ctl_path , pg_ctl_path , "pg_ctl" );
3268+ /* path to pg_ctl, properly quoted */
3269+ appendShellString (start_db_cmd , pg_ctl_path );
32593270
3260- /* path to pg_ctl, properly quoted */
3261- appendShellString (start_db_cmd , pg_ctl_path );
3271+ /* add -D switch, with properly quoted data directory */
3272+ appendPQExpBufferStr (start_db_cmd , " -D " );
3273+ appendShellString (start_db_cmd , pgdata_native );
32623274
3263- /* add -D switch, with properly quoted data directory */
3264- appendPQExpBufferStr ( start_db_cmd , " -D " );
3265- appendShellString (start_db_cmd , pgdata_native );
3275+ /* add suggested -l switch and "start" command */
3276+ /* translator: This is a placeholder in a shell command. */
3277+ appendPQExpBuffer (start_db_cmd , " -l %s start" , _ ( "logfile" ) );
32663278
3267- /* add suggested -l switch and "start" command */
3268- /* translator: This is a placeholder in a shell command. */
3269- appendPQExpBuffer ( start_db_cmd , " -l %s start" , _ ( "logfile" ) );
3279+ printf ( _ ( "\nSuccess. You can now start the database server using:\n\n"
3280+ " %s\n\n" ),
3281+ start_db_cmd -> data );
32703282
3271- printf (_ ("\nSuccess. You can now start the database server using:\n\n"
3272- " %s\n\n" ),
3273- start_db_cmd -> data );
3283+ destroyPQExpBuffer (start_db_cmd );
3284+
3285+ printf (_ ("\nSuccess.\n" ));
3286+ }
32743287
3275- destroyPQExpBuffer (start_db_cmd );
32763288
32773289 success = true;
32783290 return 0 ;
0 commit comments