Skip to content

Commit 604f4a6

Browse files
committed
Update handling of backslashes, and pg_user dump.
1 parent 6ffae20 commit 604f4a6

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/bin/pg_dump/pg_dumpall

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,29 @@
44
# dumps all databases to standard output
55
# It also dumps the pg_user table
66
#
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
715
psql -l -A -q -t|cut -d"|" -f1 | grep -v '^template1$' | \
816
while read DATABASE
917
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"
1321
pg_dump "$@" $DATABASE
1422
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;"
1725
#
1826
# Dump everyone but the postgres user
1927
# initdb creates him
2028
#
21-
POSTGRES_SUPER_USER_ID="`psql -q template1 <<END
22-
\\t
29+
POSTGRES_SUPER_USER_ID="`psql -A -q -t template1 <<END
2330
select datdba
2431
from pg_database
2532
where datname = 'template1';
@@ -31,4 +38,4 @@ where usesysid <> $POSTGRES_SUPER_USER_ID;
3138
copy tmp_pg_user to stdout;
3239
drop table tmp_pg_user;
3340
END
34-
/bin/echo '\.'
41+
echo "${BS}."

0 commit comments

Comments
 (0)