Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ca971a

Browse files
committed
Hi,
I sending promised patch with: * getopt_long() - for pg_dump (portable) * and "Usage: " changes in scripts in src/bin/ - this changes are cosmetic only, not change any feature ...etc. All PostgreSQL routines (scripts) support now long options andhelp's output is alike for all scripts and all support -? or --help. KarelKarel Zak <zakkr@zf.jcu.cz>http://home.zf.jcu.cz/~zakkr/
1 parentcf374fe commit5ca971a

File tree

11 files changed

+235
-102
lines changed

11 files changed

+235
-102
lines changed

‎src/bin/initdb/initdb.sh

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#
2727
#
2828
# IDENTIFICATION
29-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.64 1999/12/12 05:57:30 momjian Exp $
29+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.65 1999/12/16 20:09:56 momjian Exp $
3030
#
3131
#-------------------------------------------------------------------------
3232

@@ -152,27 +152,40 @@ do
152152
exit 100
153153
fi
154154
;;
155+
--help)
156+
usage=t
157+
;;
158+
-\?)
159+
usage=t
160+
;;
155161
*)
156-
echo"Unrecognized option '$1'. Syntax is:"
157-
if [-z"$MULTIBYTE" ];then
158-
echo"initdb [-t | --template] [-d | --debug]" \
159-
"[-n | --noclean]" \
160-
"[-u SUPERUSER | --username=SUPERUSER]" \
161-
"[-r DATADIR | --pgdata=DATADIR]" \
162-
"[-l LIBDIR | --pglib=LIBDIR]"
163-
else
164-
echo"initdb [-t | --template] [-d | --debug]" \
165-
"[-n | --noclean]" \
166-
"[-u SUPERUSER | --username=SUPERUSER]" \
167-
"[-r DATADIR | --pgdata=DATADIR]" \
168-
"[-l LIBDIR | --pglib=LIBDIR]" \
169-
"[-e ENCODING | --pgencoding=ENCODING]"
170-
fi
171-
exit 100
162+
echo"Unrecognized option '$1'. Try -? for help."
163+
exit 100
172164
esac
173165
shift
174166
done
175167

168+
if ["$usage" ];then
169+
echo""
170+
echo"Usage:$CMDNAME [options]"
171+
echo""
172+
echo" -t, --template"
173+
echo" -d, --debug"
174+
echo" -n, --noclean"
175+
echo" -u SUPERUSER, --username=SUPERUSER"
176+
echo" -r DATADIR, --pgdata=DATADIR"
177+
echo" -l LIBDIR, --pglib=LIBDIR"
178+
179+
if [-n"$MULTIBYTE" ];then
180+
echo" -e ENCODING, --pgencoding=ENCODING"
181+
fi
182+
183+
echo" -?, --help"
184+
echo""
185+
186+
exit 100
187+
fi
188+
176189
#-------------------------------------------------------------------------
177190
# Make sure he told us where to find the Postgres files.
178191
#-------------------------------------------------------------------------

‎src/bin/initlocation/initlocation.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#
1313
#
1414
# IDENTIFICATION
15-
# $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.2 1998/10/05 02:51:21 thomas Exp $
15+
# $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.3 1999/12/16 20:09:57 momjian Exp $
1616
#
1717
#-------------------------------------------------------------------------
1818

@@ -27,21 +27,31 @@ do
2727

2828
--location)shift; PGALTDATA="$1"; ;;
2929
--username)shift; POSTGRES_SUPERUSERNAME="$1"; ;;
30+
--help) usage=1; ;;
3031

3132
-u)shift; POSTGRES_SUPERUSERNAME="$1"; ;;
3233
-D)shift; PGALTDATA="$1"; ;;
33-
-*) badparm=$1; usage=1; ;;
34+
-h) usage=t; ;;
35+
-\?) usage=t; ;;
36+
-*) badparm=$1; ;;
3437
*) PGALTDATA="$1"; ;;
3538
esac
3639
shift
3740
done
3841

3942
if [-n"$badparm" ];then
40-
echo"$CMDNAME: Unrecognized parameter '$badparm'"
43+
echo"$CMDNAME: Unrecognized parameter '$badparm'. Try -? for help."
44+
exit 1
4145
fi
4246

43-
if [-n"$usage" ];then
44-
echo"Usage:$CMDNAME [-u SUPERUSER] DATADIR"
47+
if ["$usage" ];then
48+
echo""
49+
echo"Usage:$CMDNAME [options] datadir"
50+
echo""
51+
echo" -u SUPERUSER, --username=SUPERUSER"
52+
echo" -D DATADIR, --location=DATADIR"
53+
echo" -?, --help"
54+
echo""
4555
exit 1
4656
fi
4757

‎src/bin/pg_dump/pg_dump.c

Lines changed: 75 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
*
2323
* IDENTIFICATION
24-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.125 1999/12/11 00:31:05 momjian Exp $
24+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.126 1999/12/16 20:09:58 momjian Exp $
2525
*
2626
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
2727
*
@@ -125,42 +125,54 @@ static void
125125
usage(constchar*progname)
126126
{
127127
fprintf(stderr,
128-
"usage: %s [options] dbname\n",progname);
129-
fprintf(stderr,
130-
"\t -a \t\t dump out only the data, no schema\n");
131-
fprintf(stderr,
132-
"\t -c \t\t clean(drop) schema prior to create\n");
133-
fprintf(stderr,
134-
"\t -d \t\t dump data as proper insert strings\n");
135-
fprintf(stderr,
136-
"\t -D \t\t dump data as inserts"
137-
" with attribute names\n");
138-
fprintf(stderr,
139-
"\t -f filename \t\t script output filename\n");
140-
fprintf(stderr,
141-
"\t -h hostname \t\t server host name\n");
142-
fprintf(stderr,
143-
"\t -n \t\t suppress most quotes around identifiers\n");
144-
fprintf(stderr,
145-
"\t -N \t\t enable most quotes around identifiers\n");
146-
fprintf(stderr,
147-
"\t -o \t\t dump object id's (oids)\n");
148-
fprintf(stderr,
149-
"\t -p port \t\t server port number\n");
150-
fprintf(stderr,
151-
"\t -s \t\t dump out only the schema, no data\n");
152-
fprintf(stderr,
153-
"\t -t table \t\t dump for this table only\n");
154-
fprintf(stderr,
155-
"\t -u \t\t use password authentication\n");
128+
"\nUsage: %s [options] dbname\n\n",progname);
129+
130+
#ifdefHAVE_GETOPT_LONG
156131
fprintf(stderr,
157-
"\t -v \t\t verbose\n");
132+
133+
" -a, --data-only dump out only the data, no schema\n"
134+
" -c, --clean clean(drop) schema prior to create\n"
135+
" -d, --insert-proper dump data as proper insert strings\n"
136+
" -D, --insert-attr dump data as inserts with attribute names\n"
137+
" -f, --out file script output filename\n"
138+
" -h, --host hostname server host name\n"
139+
" -n, --no-quotes suppress most quotes around identifiers\n"
140+
" -N, --quotes enable most quotes around identifiers\n"
141+
" -o, --oids dump object id's (oids)\n"
142+
" -p, --port port server port number\n"
143+
" -s, --schema-only dump out only the schema, no data\n"
144+
" -t, --table table dump for this table only\n"
145+
" -u, --password use password authentication\n"
146+
" -v, --verbose verbose\n"
147+
" -x, --no-acl do not dump ACL's (grant/revoke)\n"
148+
" -?, --help show this help message\n"
149+
150+
);/* fprintf */
151+
#else
158152
fprintf(stderr,
159-
"\t -x \t\t do not dump ACL's (grant/revoke)\n");
153+
154+
" -a dump out only the data, no schema\n"
155+
" -c clean(drop) schema prior to create\n"
156+
" -d dump data as proper insert strings\n"
157+
" -D dump data as inserts with attribute names\n"
158+
" -f filename script output filename\n"
159+
" -h hostname server host name\n"
160+
" -n suppress most quotes around identifiers\n"
161+
" -N enable most quotes around identifiers\n"
162+
" -o dump object id's (oids)\n"
163+
" -p port server port number\n"
164+
" -s dump out only the schema, no data\n"
165+
" -t table dump for this table only\n"
166+
" -u use password authentication\n"
167+
" -v verbose\n"
168+
" -x do not dump ACL's (grant/revoke)\n"
169+
" -? show this help message\n"
170+
171+
);/* fprintf */
172+
#endif
173+
160174
fprintf(stderr,
161-
"\nIf dbname is not supplied, then the DATABASE environment "
162-
"variable value is used.\n");
163-
fprintf(stderr,"\n");
175+
"\nIf dbname is not supplied, then the DATABASE environment variable value is used.\n\n");
164176

165177
exit(1);
166178
}
@@ -534,6 +546,29 @@ main(int argc, char **argv)
534546
charpassword[100];
535547
booluse_password= false;
536548

549+
#ifdefHAVE_GETOPT_LONG
550+
staticstructoptionlong_options[]= {
551+
{"data-only",no_argument,NULL,'a'},
552+
{"clean",no_argument,NULL,'c'},
553+
{"insert-proper",no_argument,NULL,'d'},
554+
{"insert-attr",no_argument,NULL,'D'},
555+
{"out",required_argument,NULL,'f'},
556+
{"to-file",required_argument,NULL,'f'},
557+
{"host",required_argument,NULL,'h'},
558+
{"no-quotes",no_argument,NULL,'n'},
559+
{"quotes",no_argument,NULL,'N'},
560+
{"oids",no_argument,NULL,'o'},
561+
{"port",required_argument,NULL,'p'},
562+
{"schema-only",no_argument,NULL,'s'},
563+
{"table",required_argument,NULL,'t'},
564+
{"password",no_argument,NULL,'u'},
565+
{"verbose",no_argument,NULL,'v'},
566+
{"no-acl",no_argument,NULL,'x'},
567+
{"help",no_argument,NULL,'?'},
568+
};
569+
intoptindex;
570+
#endif
571+
537572
g_verbose= false;
538573
force_quotes= true;
539574
dropSchema= false;
@@ -546,7 +581,11 @@ main(int argc, char **argv)
546581

547582
progname=*argv;
548583

549-
while ((c=getopt(argc,argv,"acdDf:h:nNop:st:uvxz"))!=EOF)
584+
#ifdefHAVE_GETOPT_LONG
585+
while ((c=getopt_long(argc,argv,"acdDf:h:nNop:st:uvxz?",long_options,&optindex))!=-1)
586+
#else
587+
while ((c=getopt(argc,argv,"acdDf:h:nNop:st:uvxz?"))!=-1)
588+
#endif
550589
{
551590
switch (c)
552591
{
@@ -627,6 +666,7 @@ main(int argc, char **argv)
627666
"%s: The -z option(dump ACLs) is now the default, continuing.\n",
628667
progname);
629668
break;
669+
case'?':
630670
default:
631671
usage(progname);
632672
break;

‎src/bin/pg_encoding/pg_encoding.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/pg_encoding.c,v 1.4 1999/07/17 20:18:20 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/pg_encoding.c,v 1.5 1999/12/16 20:10:00 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -46,5 +46,5 @@ main(int argc, char **argv)
4646
staticvoid
4747
usage()
4848
{
49-
fprintf(stderr,"pg_encoding:encoding_name | encoding_number\n");
49+
fprintf(stderr,"\nUsage: pg_encodingencoding_name | encoding_number\n\n");
5050
}

‎src/bin/scripts/createdb

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
#
1313
# IDENTIFICATION
14-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.3 1999/12/0810:29:55 momjian Exp $
14+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.4 1999/12/16 20:10:02 momjian Exp $
1515
#
1616
#-------------------------------------------------------------------------
1717

@@ -28,7 +28,6 @@ do
2828
case"$1"in
2929
--help|-\?)
3030
usage=t
31-
break
3231
;;
3332
# options passed on to psql
3433
--host|-h)
@@ -104,11 +103,21 @@ do
104103
shift
105104
done
106105

107-
108106
if ["$usage" ];then
109-
echo"Usage:$CMDNAME [-h server] [-p port] [-D path]\\"
110-
echo" [-E encoding] [-U username] dbname [description]"
111-
exit 0
107+
echo""
108+
echo"Usage:$CMDNAME [options] dbname [description]"
109+
echo""
110+
echo" -h HOSTNAME, --host=HOSTNAME"
111+
echo" -p PORT, --port=PORT"
112+
echo" -U USERNAME, --username=USERNAME"
113+
echo" -W, --password"
114+
echo" -e, --echo"
115+
echo" -q, --quiet"
116+
echo" -D PATH, --location=PATH"
117+
echo" -E ENCODING --encoding=ENCODING"
118+
echo" -?, --help"
119+
echo""
120+
exit 1
112121
fi
113122

114123

‎src/bin/scripts/createlang.sh

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
#
1010
# IDENTIFICATION
11-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.2 1999/12/07 22:41:44 momjian Exp $
11+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.3 1999/12/16 20:10:02 momjian Exp $
1212
#
1313
#-------------------------------------------------------------------------
1414

@@ -51,7 +51,6 @@ do
5151
case"$1"in
5252
--help|-\?)
5353
usage=t
54-
break
5554
;;
5655
--list|-l)
5756
list=t
@@ -127,12 +126,22 @@ do
127126
shift
128127
done
129128

130-
131-
132-
if ["$usage" ];then
133-
echo"Usage:$CMDNAME [-h server] [-p port] [-U username] [-d dbname]\\"
134-
echo" [-L|--pglib PGLIB] [langname [dbname]]"
135-
exit 0
129+
if ["$usage" ];then
130+
echo""
131+
echo"Usage:$CMDNAME [options] [langname [dbname]]"
132+
echo""
133+
echo" -h HOSTNAME, --host=HOSTNAME"
134+
echo" -p PORT, --port=PORT"
135+
echo" -U USERNAME, --username=USERNAME"
136+
echo" -W, --password"
137+
echo" -d DBNAME, --database=DBNAME"
138+
echo" -e, --echo"
139+
echo" -q, --quiet"
140+
echo" -D PATH, --location=PATH"
141+
echo" -L PGLIB --pglib=PGLIB"
142+
echo" -?, --help"
143+
echo""
144+
exit 1
136145
fi
137146

138147
if ["$list" ];then

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp