Accept --help even if no general long options support exists.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.190 2000/11/25 04:13:17 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.191 2000/11/25 19:05:42 petere Exp $
*
* NOTES
*
real_argv = argv;
real_argc = argc;
+ /*
+ * Catch standard options before doing much else. This even works
+ * on systems without getopt_long.
+ */
+ if (argc > 1)
+ {
+ if (strcmp(argv[1], "--help")==0 || strcmp(argv[1], "-?")==0)
+ {
+ usage(progname);
+ exit(0);
+ }
+ if (strcmp(argv[1], "--version")==0 || strcmp(argv[1], "-V")==0)
+ {
+ puts("postmaster (PostgreSQL) " PG_VERSION);
+ exit(0);
+ }
+ }
+
+
/*
* for security, no dir or file created can be group or other
* accessible
* will occur.
*/
opterr = 1;
- while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:SsV-:?")) != EOF)
+ while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != EOF)
{
switch(opt)
{
potential_DataDir = optarg;
break;
- case 'V':
- puts("postmaster (PostgreSQL) " PG_VERSION);
- exit(0);
-
- case '-':
- {
- char *name, *value;
-
- ParseLongOption(optarg, &name, &value);
- if (strcmp(name, "help")==0)
- {
- usage(progname);
- exit(0);
- }
- else if (strcmp(name, "version")==0)
- {
- puts("postmaster (PostgreSQL) " PG_VERSION);
- exit(0);
- }
- break;
- }
-
case '?':
- if (strcmp(argv[optind - 1], "-?") == 0)
- {
- usage(progname);
- exit(0);
- }
- else
- {
- fprintf(stderr, "Try -? for help.\n");
- exit(1);
- }
- break;
+ fprintf(stderr, "Try '%s --help' for more information.\n", progname);
+ exit(1);
}
}
+ /*
+ * Non-option switch arguments don't exist.
+ */
+ if (optind < argc)
+ {
+ fprintf(stderr, "%s: invalid argument -- %s\n", progname, argv[optind]);
+ fprintf(stderr, "Try '%s --help' for more information.\n", progname);
+ exit(1);
+ }
+
checkDataDir(potential_DataDir); /* issues error messages */
SetDataDir(potential_DataDir);
#ifdef HAVE_INT_OPTRESET
optreset = 1;
#endif
- while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:SsV-:?")) != EOF)
+ while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != EOF)
{
switch (opt)
{
default:
/* shouldn't get here */
- fprintf(stderr, "Try -? for help.\n");
+ fprintf(stderr, "Try '%s --help' for more information.\n", progname);
exit(1);
}
}
- /*
- * Non-option switch arguments don't exist.
- */
- if (optind < argc)
- {
- fprintf(stderr, "%s: invalid argument -- %s\n", progname, argv[optind]);
- exit(1);
- }
-
/*
* Check for invalid combinations of switches
*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.189 2000/11/21 21:16:02 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.190 2000/11/25 19:05:42 petere Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
char *potential_DataDir = NULL;
+ /*
+ * Catch standard options before doing much else. This even works
+ * on systems without getopt_long.
+ */
+ if (!IsUnderPostmaster && argc > 1)
+ {
+ if (strcmp(argv[1], "--help")==0 || strcmp(argv[1], "-?")==0)
+ {
+ usage(argv[0]);
+ exit(0);
+ }
+ if (strcmp(argv[1], "--version")==0 || strcmp(argv[1], "-V")==0)
+ {
+ puts("postgres (PostgreSQL) " PG_VERSION);
+ exit(0);
+ }
+ }
+
/*
* Fire up essential subsystems: error and memory management
*
optind = 1; /* reset after postmaster's usage */
- while ((flag = getopt(argc, argv, "A:B:c:CD:d:Eef:FiLNOPo:p:S:st:v:VW:x:-:?")) != EOF)
+ while ((flag = getopt(argc, argv, "A:B:c:CD:d:Eef:FiLNOPo:p:S:st:v:W:x:-:")) != EOF)
switch (flag)
{
case 'A':
FrontendProtocol = (ProtocolVersion) atoi(optarg);
break;
- case 'V':
- puts("postgres (PostgreSQL) " PG_VERSION);
- exit(0);
-
case 'W':
/* ----------------
* wait N seconds to allow attach from a debugger
char *name, *value;
ParseLongOption(optarg, &name, &value);
- if (strcmp(name, "help")==0)
- {
- usage(argv[0]);
- exit(0);
- }
- else if (strcmp(name, "version")==0)
- {
- puts("postgres (PostgreSQL) " PG_VERSION);
- exit(0);
- }
if (!value)
{
if (flag == '-')
break;
}
- case '?':
- if (strcmp(argv[optind - 1], "-?") == 0)
- {
- usage(argv[0]);
- exit(0);
- }
- else
- errs++;
- break;
-
default:
- /* shouldn't get here */
errs++;
break;
}
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.189 $ $Date: 2000/11/21 21:16:02 $\n");
+ puts("$Revision: 1.190 $ $Date: 2000/11/25 19:05:42 $\n");
}
/*
#
# Copyright (c) 1994, Regents of the University of California
#
-# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.116 2000/11/21 20:55:57 tgl Exp $
+# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.117 2000/11/25 19:05:43 petere Exp $
#
#-------------------------------------------------------------------------
;;
-*)
echo "$CMDNAME: invalid option: $1"
- echo "Try '$CMDNAME -?' for help."
+ echo "Try '$CMDNAME --help' for more information."
exit 1
;;
*)
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.9 2000/11/11 22:59:46 petere Exp $
+# $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.10 2000/11/25 19:05:43 petere Exp $
#
#-------------------------------------------------------------------------
-*)
echo "$CMDNAME: invalid option: $1" 1>&2
- echo "Try '$CMDNAME -?' for help." 1>&2
+ echo "Try '$CMDNAME --help' for more information." 1>&2
exit 1
;;
*)
if (argc != 2)
{
- fprintf(stderr, "%s: too %s arguments\nTry '%s -?' for help.\n",
+ fprintf(stderr, "%s: too %s arguments\nTry '%s --help' for more information.\n",
progname, argc > 2 ? "many" : "few", progname);
exit(1);
}
}
if (argv[1][0] == '-')
{
- fprintf(stderr, "%s: invalid option: %s\nTry '%s -?' for help.\n",
+ fprintf(stderr, "%s: invalid option: %s\nTry '%s --help' for more information.\n",
progname, argv[1], progname);
exit(1);
}
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.39 2000/11/13 23:37:53 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.40 2000/11/25 19:05:44 petere Exp $
*/
#include "postgres.h"
else
pset.progname = strrchr(argv[0], SEP_CHAR) + 1;
+ if (argc > 1)
+ {
+ if (strcmp(argv[1], "--help")==0 || strcmp(argv[1], "-?")==0)
+ {
+ usage();
+ exit(EXIT_SUCCESS);
+ }
+ if (strcmp(argv[1], "--version")==0 || strcmp(argv[1], "-V")==0)
+ {
+ showVersion();
+ exit(EXIT_SUCCESS);
+ }
+ }
+
pset.cur_cmd_source = stdin;
pset.cur_cmd_interactive = false;
pset.encoding = PQenv2encoding();
/* unknown option reported by getopt */
else
{
- fputs("Try -? for help.\n", stderr);
+ fprintf(stderr, "Try '%s --help' for more information.\n",
+ pset.progname);
exit(EXIT_FAILURE);
}
break;
#ifndef HAVE_GETOPT_LONG
case '-':
fprintf(stderr, "%s was compiled without support for long options.\n"
- "Use -? for help on invocation options.\n", pset.progname);
+ "Use --help for help on invocation options.\n", pset.progname);
exit(EXIT_FAILURE);
break;
#endif
default:
- fputs("Try -? for help.\n", stderr);
+ fprintf(stderr, "Try '%s --help' for more information.\n",
+ pset.progname);
exit(EXIT_FAILURE);
break;
}
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.11 2000/11/13 23:37:53 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.12 2000/11/25 19:05:44 petere Exp $
#
#-------------------------------------------------------------------------
;;
-*)
echo "$CMDNAME: invalid option: $1" 1>&2
- echo "Try '$CMDNAME -?' for help." 1>&2
+ echo "Try '$CMDNAME --help' for more information." 1>&2
exit 1
;;
*)
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.20 2000/11/20 20:36:50 tgl Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.21 2000/11/25 19:05:44 petere Exp $
#
#-------------------------------------------------------------------------
-*)
echo "$CMDNAME: invalid option: $1" 1>&2
- echo "Try '$CMDNAME -?' for help." 1>&2
+ echo "Try '$CMDNAME --help' for more information." 1>&2
exit 1
;;
*)
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.14 2000/11/13 23:37:53 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.15 2000/11/25 19:05:44 petere Exp $
#
# Note - this should NOT be setuid.
#
;;
-*)
echo "$CMDNAME: invalid option: $1" 1>&2
- echo "Try '$CMDNAME -?' for help." 1>&2
+ echo "Try '$CMDNAME --help' for more information." 1>&2
exit 1
;;
*)
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.9 2000/11/13 23:37:53 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.10 2000/11/25 19:05:44 petere Exp $
#
#-------------------------------------------------------------------------
;;
-*)
echo "$CMDNAME: invalid option: $1" 1>&2
- echo "Try '$CMDNAME -?' for help." 1>&2
+ echo "Try '$CMDNAME --help' for more information." 1>&2
exit 1
;;
*)
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.10 2000/11/13 23:37:53 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.11 2000/11/25 19:05:44 petere Exp $
#
#-------------------------------------------------------------------------
-*)
echo "$CMDNAME: invalid option: $1" 1>&2
- echo "Try '$CMDNAME -?' for help." 1>&2
+ echo "Try '$CMDNAME --help' for more information." 1>&2
exit 1
;;
*)
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.9 2000/11/13 23:37:53 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.10 2000/11/25 19:05:44 petere Exp $
#
# Note - this should NOT be setuid.
#
;;
-*)
echo "$CMDNAME: invalid option: $1" 1>&2
- echo "Try '$CMDNAME -?' for help." 1>&2
+ echo "Try '$CMDNAME --help' for more information." 1>&2
exit 1
;;
*)
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.12 2000/11/13 23:37:53 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.13 2000/11/25 19:05:44 petere Exp $
#
#-------------------------------------------------------------------------
-*)
echo "$CMDNAME: invalid option: $1" 1>&2
- echo "Try '$CMDNAME -?' for help." 1>&2
+ echo "Try '$CMDNAME --help' for more information." 1>&2
exit 1
;;
*)