File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change 4
4
# dumps all databases to standard output
5
5
# It also dumps the pg_user table
6
6
#
7
+ # to adapt to System V vs. BSD 'echo'
8
+ set -x
9
+ if echo ' \\' | grep ' \\\\' > /dev/null 2>&1
10
+ then
11
+ BS=' \' # BSD
12
+ else
13
+ BS=' \\' # System V
14
+ fi
7
15
psql -l -A -q -t| cut -d" |" -f1 | grep -v ' ^template1$' | \
8
16
while read DATABASE
9
17
do
10
- /bin/ echo ' \ connect template1'
11
- /bin/ echo " create database $DATABASE ;"
12
- /bin/ echo ' \ connect' " $DATABASE "
18
+ echo " ${BS} connect template1"
19
+ echo " create database $DATABASE ;"
20
+ echo " ${BS} connect $DATABASE "
13
21
pg_dump " $@ " $DATABASE
14
22
done
15
- /bin/ echo ' \ connect template1'
16
- /bin/ echo ' copy pg_user from stdin;'
23
+ echo " ${BS} connect template1"
24
+ echo " copy pg_user from stdin;"
17
25
#
18
26
# Dump everyone but the postgres user
19
27
# initdb creates him
20
28
#
21
- POSTGRES_SUPER_USER_ID=" ` psql -q template1 << END
22
- \\ t
29
+ POSTGRES_SUPER_USER_ID=" ` psql -A -q -t template1 << END
23
30
select datdba
24
31
from pg_database
25
32
where datname = 'template1';
@@ -31,4 +38,4 @@ where usesysid <> $POSTGRES_SUPER_USER_ID;
31
38
copy tmp_pg_user to stdout;
32
39
drop table tmp_pg_user;
33
40
END
34
- /bin/ echo '\.'
41
+ echo " ${BS} . "
You can’t perform that action at this time.
0 commit comments