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

Commit3903296

Browse files
committed
From: Igor <igor@sba.miami.edu>
Subject: [PATCHES] destroydb patchI am including a patch for destroydb to ask for confirmation beforedeleting databases (after I accidentally deleted mine)...destroydb -ywould force delete without any confirmation.
1 parent9a5529f commit3903296

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

‎src/bin/destroydb/destroydb.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
#
1313
# IDENTIFICATION
14-
# $Header: /cvsroot/pgsql/src/bin/destroydb/Attic/destroydb.sh,v 1.6 1996/11/17 03:54:58 bryanh Exp $
14+
# $Header: /cvsroot/pgsql/src/bin/destroydb/Attic/destroydb.sh,v 1.7 1997/06/01 15:40:08 scrappy Exp $
1515
#
1616
#-------------------------------------------------------------------------
1717

@@ -30,18 +30,18 @@ if [ -z "$USER" ]; then
3030
fi
3131

3232
dbname=$USER
33-
33+
forcedel=f
3434
while [-n"$1" ]
3535
do
3636
case$1in
37+
-y) forcedel=t;;
3738
-a) AUTHSYS=$2;shift;;
3839
-h) PGHOST=$2;shift;;
3940
-p) PGPORT=$2;shift;;
4041
*) dbname=$1;;
4142
esac
4243
shift;
4344
done
44-
4545
if [-z"$AUTHSYS" ];then
4646
AUTHOPT=""
4747
else
@@ -60,12 +60,25 @@ else
6060
PGPORTOPT="-p$PGPORT"
6161
fi
6262

63-
psql -tq$AUTHOPT$PGHOSTOPT$PGPORTOPT -c"drop database$dbname" template1
63+
answer=y
64+
if ["$forcedel"= f ]
65+
then
66+
answer=f
6467

65-
if [$?-ne 0 ]
68+
while ["$answer"!= y-a"$answer"!= n ]
69+
do
70+
echo -n"Are you sure? (y/n)"
71+
read answer
72+
done
73+
fi
74+
75+
if ["$answer"= y ]
6676
then
67-
echo"$CMDNAME: database destroy failed on$dbname."
68-
exit 1
77+
psql -tq$AUTHOPT$PGHOSTOPT$PGPORTOPT -c"drop database$dbname" template1
78+
if [$?-ne 0 ]
79+
thenecho"$CMDNAME: database destroy failed on$dbname."
80+
exit 1
81+
fi
6982
fi
7083

7184
exit 0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp