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

Commit8095924

Browse files
committed
Make sure shell scripts send error messages to stderr.
Improve help output.Teach droplang to remove 'pltclu'.
1 parentb9c8fae commit8095924

File tree

11 files changed

+141
-109
lines changed

11 files changed

+141
-109
lines changed

‎src/bin/initdb/initdb.sh

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#
2424
# Copyright (c) 1994, Regents of the University of California
2525
#
26-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.112 2000/11/09 11:26:00 vadim Exp $
26+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.113 2000/11/11 22:59:46 petere Exp $
2727
#
2828
#-------------------------------------------------------------------------
2929

@@ -34,17 +34,17 @@
3434

3535
exit_nicely(){
3636
sttyecho> /dev/null2>&1
37-
echo
38-
echo"$CMDNAME failed."
37+
echo1>&2
38+
echo"$CMDNAME failed."1>&2
3939
if ["$noclean"!= yes ];then
4040
if ["$template_only"!= yes ]&& ["$made_new_pgdata"= yes ];then
41-
echo"Removing$PGDATA."
42-
rm -rf"$PGDATA"||echo"Failed."
41+
echo"Removing$PGDATA."1>&2
42+
rm -rf"$PGDATA"||echo"Failed."1>&2
4343
fi
44-
echo"Removing temp file$TEMPFILE."
45-
rm -rf"$TEMPFILE"||echo"Failed."
44+
echo"Removing temp file$TEMPFILE."1>&2
45+
rm -rf"$TEMPFILE"||echo"Failed."1>&2
4646
else
47-
echo"Data directory$PGDATA will not be removed at user's request."
47+
echo"Data directory$PGDATA will not be removed at user's request."1>&2
4848
fi
4949
exit 1
5050
}
@@ -117,43 +117,43 @@ elif [ -x "$bindir/postgres" ]; then
117117
then
118118
PGPATH=$bindir
119119
else
120-
echo"The program '$bindir/postgres' needed by$CMDNAME does not belong to"
121-
echo"PostgreSQL version$VERSION. Check your installation."
120+
echo"The program '$bindir/postgres' needed by$CMDNAME does not belong to"1>&2
121+
echo"PostgreSQL version$VERSION. Check your installation."1>&2
122122
exit 1
123123
fi
124124
else
125-
echo"The program 'postgres' is needed by$CMDNAME but was not found in"
126-
echo"the directory '$bindir'. Check your installation."
125+
echo"The program 'postgres' is needed by$CMDNAME but was not found in"1>&2
126+
echo"the directory '$bindir'. Check your installation."1>&2
127127
exit 1
128128
fi
129129

130130

131131
# Now we can assume that 'pg_id' belongs to the same version as the
132132
# verified 'postgres' in the same directory.
133133
if [!-x"$PGPATH/pg_id" ];then
134-
echo"The program 'pg_id' is needed by$CMDNAME but was not found in"
135-
echo"the directory '$PGPATH'. Check your installation."
134+
echo"The program 'pg_id' is needed by$CMDNAME but was not found in"1>&2
135+
echo"the directory '$PGPATH'. Check your installation."1>&2
136136
exit 1
137137
fi
138138

139139

140140
EffectiveUser=`$PGPATH/pg_id -n -u`
141141
if [-z"$EffectiveUser" ];then
142-
echo"$CMDNAME: could not determine current user name"
142+
echo"$CMDNAME: could not determine current user name"1>&2
143143
exit 1
144144
fi
145145

146146
if [`$PGPATH/pg_id -u`-eq 0 ]
147147
then
148-
echo"You cannot run$CMDNAME as root. Please log in (using, e.g., 'su')"
149-
echo"as the (unprivileged) user that will own the server process."
148+
echo"You cannot run$CMDNAME as root. Please log in (using, e.g., 'su')"1>&2
149+
echo"as the (unprivileged) user that will own the server process."1>&2
150150
exit 1
151151
fi
152152

153153

154154
short_version=`echo$VERSION| sed -e's!^\([0-9][0-9]*\.[0-9][0-9]*\).*!\1!'`
155155
if [ x"$short_version"= x"" ];then
156-
echo"$CMDNAME: bug: version numberis out offormat"
156+
echo"$CMDNAME: bug: version numberhas wrongformat"1>&2
157157
exit 1
158158
fi
159159

@@ -252,7 +252,7 @@ do
252252
;;
253253
-*)
254254
echo"$CMDNAME: invalid option:$1"
255-
echo"Try-? for help."
255+
echo"Try'$CMDNAME -?' for help."
256256
exit 1
257257
;;
258258
*)
@@ -263,20 +263,20 @@ do
263263
done
264264

265265
if ["$usage" ];then
266-
echo"$CMDNAMEinitialized a PostgreSQL database cluster."
266+
echo"$CMDNAMEinitializes a PostgreSQL database cluster."
267267
echo
268268
echo"Usage:"
269269
echo"$CMDNAME [options] datadir"
270270
echo
271271
echo"Options:"
272-
echo" [-D, --pgdata]<datadir> Location for this database cluster"
272+
echo" [-D, --pgdata]DATADIR Location for this database cluster"
273273
echo" -W, --pwprompt Prompt for a password for the new superuser"
274274
if [-n"$MULTIBYTE" ];then
275-
echo" -E, --encoding<encoding> Set the default multibyte encoding for new databases"
275+
echo" -E, --encodingENCODING Set the default multibyte encoding for new databases"
276276
fi
277-
echo" -i, --sysid<sysid> Database sysid for the superuser"
277+
echo" -i, --sysidSYSID Database sysid for the superuser"
278278
echo"Less commonly used options:"
279-
echo" -L<directory> Where to find the input files"
279+
echo" -LDIRECTORY Where to find the input files"
280280
echo" -t, --template Re-initialize template database only"
281281
echo" -d, --debug Generate lots of debugging output"
282282
echo" -n, --noclean Do not clean up after errors"
@@ -294,15 +294,17 @@ then
294294
MULTIBYTEID=`$PGPATH/pg_encoding$MULTIBYTE`
295295
if ["$?"-ne 0 ]
296296
then
297+
(
297298
echo"$CMDNAME: pg_encoding failed"
298299
echo
299300
echo"Perhaps you did not configure PostgreSQL for multibyte support or"
300301
echo"the program was not successfully installed."
302+
)1>&2
301303
exit 1
302304
fi
303305
if [-z"$MULTIBYTEID" ]
304306
then
305-
echo"$CMDNAME:$MULTIBYTE is not a valid encoding name"
307+
echo"$CMDNAME:$MULTIBYTE is not a valid encoding name"1>&2
306308
exit 1
307309
fi
308310
fi
@@ -314,10 +316,11 @@ fi
314316

315317
if [-z"$PGDATA" ]
316318
then
319+
(
317320
echo"$CMDNAME: You must identify where the the data for this database"
318321
echo"system will reside. Do this with either a -D invocation"
319322
echo"option or a PGDATA environment variable."
320-
echo
323+
)1>&2
321324
exit 1
322325
fi
323326

@@ -353,18 +356,22 @@ fi
353356
forPREREQ_FILEin"$TEMPLATE1_BKI""$GLOBAL_BKI""$PG_HBA_SAMPLE"
354357
do
355358
if [!-f"$PREREQ_FILE" ];then
359+
(
356360
echo"$CMDNAME does not find the file '$PREREQ_FILE'."
357361
echo"This means you have a corrupted installation or identified the"
358362
echo"wrong directory with the -L invocation option."
363+
)1>&2
359364
exit 1
360365
fi
361366
done
362367

363368
forfilein"$TEMPLATE1_BKI""$GLOBAL_BKI";do
364369
if [ x"`sed 1q$file`"!= x"# PostgreSQL$short_version" ];then
370+
(
365371
echo"The input file '$file' needed by$CMDNAME does not"
366372
echo"belong to PostgreSQL$VERSION. Check your installation or specify the"
367373
echo"correct path using the -L option."
374+
)1>&2
368375
exit 1
369376
fi
370377
done
@@ -391,10 +398,12 @@ if [ x"$pgdata_contents" != x ]
391398
then
392399
if ["$template_only"!= yes ]
393400
then
401+
(
394402
echo"$CMDNAME: The directory$PGDATA is exists but is not empty."
395403
echo"If you want to create a new database system, either remove or empty"
396404
echo"the directory$PGDATA or run initdb with an argument"
397405
echo"other than$PGDATA."
406+
)1>&2
398407
exit 1
399408
fi
400409
else
@@ -509,13 +518,13 @@ if [ "$PwPrompt" ]; then
509518
sttyecho> /dev/null2>&1
510519
echo
511520
if ["$FirstPw"!="$SecondPw" ];then
512-
echo"Passwords didn't match."
521+
echo"Passwords didn't match."1>&2
513522
exit_nicely
514523
fi
515524
echo"ALTER USER\"$POSTGRES_SUPERUSERNAME\" WITH PASSWORD '$FirstPw'" \
516525
|"$PGPATH"/postgres$PGSQL_OPT template1> /dev/null|| exit_nicely
517526
if [!-f$PGDATA/pg_pwd ];then
518-
echo"The password file wasn't generated. Please report this problem."
527+
echo"The password file wasn't generated. Please report this problem."1>&2
519528
exit_nicely
520529
fi
521530
echo"Setting password"

‎src/bin/initlocation/initlocation.sh

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
#
1010
# IDENTIFICATION
11-
# $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.8 2000/05/26 03:15:18 momjian Exp $
11+
# $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.9 2000/11/11 22:59:46 petere Exp $
1212
#
1313
#-------------------------------------------------------------------------
1414

@@ -50,8 +50,8 @@ do
5050
break;;
5151

5252
-*)
53-
echo"$CMDNAME:unrecognized option$badparm"
54-
echo"Try-? for help."
53+
echo"$CMDNAME:invalid option:$1"1>&2
54+
echo"Try'$CMDNAME -?' for help."1>&2
5555
exit 1
5656
;;
5757
*)
@@ -66,16 +66,18 @@ if [ "$usage" ]; then
6666
echo"$CMDNAME initializes an alternative filesystem location for database creation."
6767
echo""
6868
echo"Usage:"
69-
echo"$CMDNAME <location>"
70-
echo""
69+
echo"$CMDNAME LOCATION"
70+
echo
71+
echo"Please read the description of the CREATE DATABASE command for details."
72+
echo
7173
echo"Report bugs to <pgsql-bugs@postgresql.org>."
7274
exit 0
7375
fi
7476

7577

7678
if [-z"$Location" ];then
77-
echo"$CMDNAME: missing required argument<location>"
78-
echo"Try-? for help."
79+
echo"$CMDNAME: missing required argumentLOCATION"1>&2
80+
echo"Try'$CMDNAME -?' for help."1>&2
7981
exit 1
8082
fi
8183

@@ -99,7 +101,7 @@ echo "$Location" | grep '/' >/dev/null 2>&1
99101
if ["$?"-ne 0-a!-d"$Location" ];then
100102
PGALTDATA=`printenv$Location2> /dev/null`
101103
if [-z"$PGALTDATA" ];then
102-
echo"$CMDNAME: environment variable$Location not set"
104+
echo"$CMDNAME: environment variable$Location not set"1>&2
103105
exit 1
104106
fi
105107
haveenv=t
@@ -126,8 +128,8 @@ if [ ! -d $PGALTDATA ]; then
126128
echo"Creating directory$PGALTDATA"
127129
mkdir"$PGALTDATA"
128130
if [$?-ne 0 ];then
129-
echo"$CMDNAME: could not create$PGALTDATA"
130-
echo"Make sure$PGALTDATA is a valid path and that you have permission to access it."
131+
echo"$CMDNAME: could not create$PGALTDATA"1>&2
132+
echo"Make sure$PGALTDATA is a valid path and that you have permission to access it."1>&2
131133
exit_nicely
132134
fi
133135
else
@@ -140,8 +142,8 @@ if [ ! -d $PGALTDATA/base ]; then
140142
echo"Creating directory$PGALTDATA/base"
141143
mkdir"$PGALTDATA/base"
142144
if [$?-ne 0 ];then
143-
echo"$CMDNAME: could not create$PGALTDATA/base"
144-
echo"Make sure$PGALTDATA/base is a valid path and that you have permission to access it."
145+
echo"$CMDNAME: could not create$PGALTDATA/base"1>&2
146+
echo"Make sure$PGALTDATA/base is a valid path and that you have permission to access it."1>&2
145147
exit_nicely
146148
fi
147149
else

‎src/bin/ipcclean/ipcclean.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
#
3-
# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.5 2000/03/25 14:44:41 momjian Exp $
3+
# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.6 2000/11/11 22:59:47 petere Exp $
44
#
55

66
CMDNAME=`basename$0`
@@ -20,8 +20,10 @@ fi
2020

2121
if ["$USER"='root'-o"$LOGNAME"='root' ]
2222
then
23+
(
2324
echo"You cannot run$CMDNAME as root. Please log in (using, e.g., 'su')"
2425
echo"as the (unprivileged) user that owned the server process."
26+
)1>&2
2527
exit 1
2628
fi
2729

@@ -42,7 +44,7 @@ if [ `uname` = 'Linux' ]; then
4244
did_anything=
4345

4446
if ps x| grep -s'postmaster'>/dev/null2>&1;then
45-
echo"$CMDNAME: You still have a postmaster running."
47+
echo"$CMDNAME: You still have a postmaster running."1>&2
4648
exit 1
4749
fi
4850

‎src/bin/pg_config/pg_config.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Author: Peter Eisentraut <peter_e@gmx.net>
88
# Public domain
99

10-
# $Header: /cvsroot/pgsql/src/bin/pg_config/Attic/pg_config.sh,v 1.1 2000/10/10 22:01:55 momjian Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/pg_config/Attic/pg_config.sh,v 1.2 2000/11/11 22:59:47 petere Exp $
1111

1212
me=`basename$0`
1313

@@ -27,18 +27,18 @@ Operation modes:
2727
--bindir show location of user executables
2828
--includedir show location of C header files
2929
--libdir show location of object code libraries
30-
--configure show options given to\`configure' script when
30+
--configure show options given to'configure' script when
3131
PostgreSQL was built
3232
--version show PostgreSQL version and exit
3333
3434
Report bugs to <pgsql-bugs@postgresql.org>."
3535

3636
advice="\
37-
Try\`$me --help' for more information."
37+
Try'$me --help' for more information."
3838

3939
iftest$# -eq 0;then
40-
echo"$me: argument required"
41-
echo"$advice"
40+
echo"$me: argument required"1>&2
41+
echo"$advice"1>&2
4242
exit 1
4343
fi
4444

@@ -56,8 +56,8 @@ do
5656
exit 0;;
5757
--help|-\?)echo"$help"
5858
exit 0;;
59-
*)echo"$me: invalid argument:$opt"
60-
echo"$advice"
59+
*)echo"$me: invalid argument:$opt"1>&2
60+
echo"$advice"1>&2
6161
exit 1;;
6262
esac
6363
done

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp