diff options
author | Duncan Overbruck <mail@duncano.de> | 2020-02-05 16:07:41 +0100 |
---|---|---|
committer | Leah Neukirchen <chneukirchen@gmail.com> | 2020-05-15 18:41:13 +0200 |
commit | b79e38b6869fa675a33b7b97fbb129b928494082 (patch) | |
tree | 1cd6d3282f722d22023caf71724a6c9b75cdd2f1 | |
parent | 064563473346b3fd7c60cc170ed406af22c7ba7a (diff) | |
download | mblaze-b79e38b6869fa675a33b7b97fbb129b928494082.tar.gz mblaze-b79e38b6869fa675a33b7b97fbb129b928494082.tar.xz mblaze-b79e38b6869fa675a33b7b97fbb129b928494082.zip |
mpick: improve unknown binding error and add test case
-rw-r--r-- | mpick.c | 6 | ||||
-rwxr-xr-x | t/2000-mpick.t | 5 |
2 files changed, 7 insertions, 4 deletions
diff --git a/mpick.c b/mpick.c index d72301c..5fcb308 100644 --- a/mpick.c +++ b/mpick.c @@ -423,6 +423,7 @@ parse_binding() struct binding *b; char *s; size_t l = 0; + struct pos savepos = { pos, line, linenr }; if (parse_ident(&s, &l)) { for (sc = scopeq; sc; sc = sc->prev) { @@ -436,9 +437,8 @@ parse_binding() } } } - // back to the start of the ident if there was one - pos = pos-l; - parse_error_at(NULL, "unknown expression"); + + parse_error_at(&savepos, "unknown expression"); return 0; } diff --git a/t/2000-mpick.t b/t/2000-mpick.t index 3cff87e..0b1296c 100755 --- a/t/2000-mpick.t +++ b/t/2000-mpick.t @@ -1,7 +1,7 @@ #!/bin/sh -e cd ${0%/*} . ./lib.sh -plan 27 +plan 28 rm -rf test.dir mkdir test.dir @@ -82,6 +82,9 @@ check_same 'create file' 'mlist inbox | mpick -t "print >\"foo\" && skip" && cat check_same 'overwrite file' 'mlist inbox | mpick -t "print >\"foo\" && skip" && cat foo' 'mlist inbox' check_same 'append file' 'mlist inbox | mpick -t "print >>\"foo\" && skip" && cat foo' 'mlist inbox && mlist inbox' +check_same 'unknown ident' 'mlist inbox | mpick -t "let x = x in x" 2>&1' \ + "echo \"mpick: parse error: argv:1:9: unknown expression at 'x in x'\"" + cat <<! >expr let foo = from.addr == "peter@example.org" let bar = from.disp == "Peter Example" |