summaryrefslogtreecommitdiffstats
path: root/src/db_bootstrap.sed
blob: 60b82431bbbf50507f45ac63f26e81e52cb25466 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Input to this is sql/hlr.sql.
#
# We want each SQL statement line wrapped in "...\n", and each end (";") to
# become a comma:
#
#   SOME SQL COMMAND (
#     that may span )
#   MULTIPLE LINES;
#   MORE;
#
# -->
#
#   "SOME SQL COMMAND (\n"
#   "  that may span )\n"
#   "MULTIPLE LINES\n",   <--note the comma here
#   "MORE\n",
#
# just replacing ';' with '\n,' won't work, since sed is bad in printing
# multiple lines. Also, how to input newlines to sed is not portable across
# platforms.

# Match excluding a trailing ';' as \1, keep any trailing ';' in \2
s/^\(.*[^;]\)\(;\|\)$/"\1\\n"\2/
# Replace trailing ';' as ','
s/;$/,/