Artifact
4532df2c904f035fc2a3be3bca6c5514def515a8:
0000: 23 0a 23 20 43 6f 70 79 72 69 67 68 74 20 28 63 #.# Copyright (c
0010: 29 20 32 30 31 32 20 44 2e 20 52 69 63 68 61 72 ) 2012 D. Richar
0020: 64 20 48 69 70 70 0a 23 0a 23 20 54 68 69 73 20 d Hipp.#.# This
0030: 70 72 6f 67 72 61 6d 20 69 73 20 66 72 65 65 20 program is free
0040: 73 6f 66 74 77 61 72 65 3b 20 79 6f 75 20 63 61 software; you ca
0050: 6e 20 72 65 64 69 73 74 72 69 62 75 74 65 20 69 n redistribute i
0060: 74 20 61 6e 64 2f 6f 72 0a 23 20 6d 6f 64 69 66 t and/or.# modif
0070: 79 20 69 74 20 75 6e 64 65 72 20 74 68 65 20 74 y it under the t
0080: 65 72 6d 73 20 6f 66 20 74 68 65 20 53 69 6d 70 erms of the Simp
0090: 6c 69 66 69 65 64 20 42 53 44 20 4c 69 63 65 6e lified BSD Licen
00a0: 73 65 20 28 61 6c 73 6f 0a 23 20 6b 6e 6f 77 6e se (also.# known
00b0: 20 61 73 20 74 68 65 20 22 32 2d 43 6c 61 75 73 as the "2-Claus
00c0: 65 20 4c 69 63 65 6e 73 65 22 20 6f 72 20 22 46 e License" or "F
00d0: 72 65 65 42 53 44 20 4c 69 63 65 6e 73 65 22 2e reeBSD License".
00e0: 29 0a 23 0a 23 20 54 68 69 73 20 70 72 6f 67 72 ).#.# This progr
00f0: 61 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 65 am is distribute
0100: 64 20 69 6e 20 74 68 65 20 68 6f 70 65 20 74 68 d in the hope th
0110: 61 74 20 69 74 20 77 69 6c 6c 20 62 65 20 75 73 at it will be us
0120: 65 66 75 6c 2c 0a 23 20 62 75 74 20 77 69 74 68 eful,.# but with
0130: 6f 75 74 20 61 6e 79 20 77 61 72 72 61 6e 74 79 out any warranty
0140: 3b 20 77 69 74 68 6f 75 74 20 65 76 65 6e 20 74 ; without even t
0150: 68 65 20 69 6d 70 6c 69 65 64 20 77 61 72 72 61 he implied warra
0160: 6e 74 79 20 6f 66 0a 23 20 6d 65 72 63 68 61 6e nty of.# merchan
0170: 74 61 62 69 6c 69 74 79 20 6f 72 20 66 69 74 6e tability or fitn
0180: 65 73 73 20 66 6f 72 20 61 20 70 61 72 74 69 63 ess for a partic
0190: 75 6c 61 72 20 70 75 72 70 6f 73 65 2e 0a 23 0a ular purpose..#.
01a0: 23 20 41 75 74 68 6f 72 20 63 6f 6e 74 61 63 74 # Author contact
01b0: 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 3a 0a 23 20 information:.#
01c0: 20 20 64 72 68 40 68 77 61 63 69 2e 63 6f 6d 0a drh@hwaci.com.
01d0: 23 20 20 20 68 74 74 70 3a 2f 2f 77 77 77 2e 68 # http://www.h
01e0: 77 61 63 69 2e 63 6f 6d 2f 64 72 68 2f 0a 23 0a waci.com/drh/.#.
01f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0200: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0210: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0220: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0230: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 0a 23 ############.#.#
0240: 20 54 65 73 74 20 63 6f 6d 6d 61 6e 64 20 6c 69 Test command li
0250: 6e 65 20 70 61 72 73 69 6e 67 0a 23 0a 0a 70 72 ne parsing.#..pr
0260: 6f 63 20 63 6d 64 2d 6c 69 6e 65 20 7b 74 65 73 oc cmd-line {tes
0270: 74 6e 61 6d 65 20 61 72 67 73 7d 20 7b 0a 20 20 tname args} {.
0280: 73 65 74 20 69 20 31 0a 20 20 66 6f 72 65 61 63 set i 1. foreac
0290: 68 20 7b 63 6d 64 6c 69 6e 65 20 72 65 73 75 6c h {cmdline resul
02a0: 74 7d 20 24 61 72 67 73 20 7b 0a 20 20 20 20 66 t} $args {. f
02b0: 6f 73 73 69 6c 20 74 65 73 74 2d 65 63 68 6f 20 ossil test-echo
02c0: 24 63 6d 64 6c 69 6e 65 0a 20 20 20 20 74 65 73 $cmdline. tes
02d0: 74 20 63 6d 64 2d 6c 69 6e 65 2d 24 74 65 73 74 t cmd-line-$test
02e0: 6e 61 6d 65 2e 24 69 20 7b 5b 6c 72 61 6e 67 65 name.$i {[lrange
02f0: 20 5b 73 70 6c 69 74 20 24 3a 3a 52 45 53 55 4c [split $::RESUL
0300: 54 20 5c 6e 5d 20 33 20 65 6e 64 5d 3d 3d 22 5c T \n] 3 end]=="\
0310: 7b 61 72 67 76 5c 5b 32 5c 5d 20 3d 20 5c 5b 24 {argv\[2\] = \[$
0320: 72 65 73 75 6c 74 5c 5d 5c 7d 22 7d 0a 20 20 20 result\]\}"}.
0330: 20 69 6e 63 72 20 69 0a 20 20 7d 0a 7d 0a 63 6d incr i. }.}.cm
0340: 64 2d 6c 69 6e 65 20 31 30 30 20 61 62 63 20 61 d-line 100 abc a
0350: 62 63 20 61 5c 22 62 63 20 61 5c 22 62 63 20 5c bc a\"bc a\"bc \
0360: 22 61 62 63 5c 22 20 5c 22 61 62 63 5c 22 0a 63 "abc\" \"abc\".c
0370: 6d 64 2d 6c 69 6e 65 20 31 30 31 20 2a 20 2a 20 md-line 101 * *
0380: 2a 2e 2a 20 2a 2e 2a 0a *.* *.*.