Neels Hofmeyr | 4655e6f | 2018-12-04 14:13:47 +0100 | [diff] [blame] | 1 | # Input to this are sql/*.sql files. |
Neels Hofmeyr | 7750d2c | 2017-10-24 23:26:27 +0200 | [diff] [blame] | 2 | # |
| 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 |
| 23 | s/^\(.*[^;]\)\(;\|\)$/"\1\\n"\2/ |
| 24 | # Replace trailing ';' as ',' |
| 25 | s/;$/,/ |