]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2968] Document the sed command
authorMukund Sivaraman <muks@isc.org>
Mon, 10 Jun 2013 09:53:51 +0000 (15:23 +0530)
committerMukund Sivaraman <muks@isc.org>
Mon, 10 Jun 2013 09:53:58 +0000 (15:23 +0530)
src/bin/dbutil/tests/dbutil_test.sh.in

index 6611b4ab8871fb1b6b41235d1bd762828c94ffa0..e11c01b2a1cc997dbad08ecb746884d226a784fe 100755 (executable)
@@ -140,6 +140,21 @@ get_schema() {
     db1=@abs_builddir@/dbutil_test_schema_$$
     copy_file $1 $db1
 
+    # The purpose of the following sed command is to join multi-line SQL
+    # statements to form single-line SQL statements.
+    #
+    # The sed command is explained as follows:
+    # ':a' creates a new label "a"
+    # 'N' appends the next line to the pattern space
+    # '$!ba' if it's not the last line, branch to "a"
+    #
+    # The above makes sed loop over the entire sqlite3 output. At this
+    # point, the pattern space contain all lines in the sqlite3 output.
+    #
+    # 's/,[\ ]*\n/, /g' then substitutes lines trailing with comma
+    # followed by zero or more spaces and the newline character, with
+    # just a comma and a single space.
+
     db_schema=`sqlite3 $db1 '.schema' | \
                sed -e ':a' -e 'N' -e '$!ba' -e 's/,[\ ]*\n/, /g' | \
                sort | \