blob: 1d301f871beb5f78eaea4a3385323b205639da4b [file] [log] [blame]
Neels Hofmeyr4655e6f2018-12-04 14:13:47 +01001# Input to this are sql/*.sql files.
Neels Hofmeyr7750d2c2017-10-24 23:26:27 +02002#
3# We want each SQL statement line wrapped in "...\n", and each end (";") to
4# become a comma:
5#
6# SOME SQL COMMAND (
7# that may span )
8# MULTIPLE LINES;
9# MORE;
10#
11# -->
12#
13# "SOME SQL COMMAND (\n"
14# " that may span )\n"
15# "MULTIPLE LINES\n", <--note the comma here
16# "MORE\n",
17#
18# just replacing ';' with '\n,' won't work, since sed is bad in printing
19# multiple lines. Also, how to input newlines to sed is not portable across
20# platforms.
21
22# Match excluding a trailing ';' as \1, keep any trailing ';' in \2
23s/^\(.*[^;]\)\(;\|\)$/"\1\\n"\2/
24# Replace trailing ';' as ','
25s/;$/,/