From aaaad5c4d2196adb4907f09d161bf8f9146fa0ae Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 7 Apr 2023 12:30:32 +0000 Subject: Better error reporting in execlineb Signed-off-by: Laurent Bercot --- src/execline/execlineb.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/execline/execlineb.c b/src/execline/execlineb.c index c115b72..89688f6 100644 --- a/src/execline/execlineb.c +++ b/src/execline/execlineb.c @@ -105,7 +105,18 @@ int main (int argc, char const *const *argv, char const *const *envp) } argc -= l.ind ; argv += l.ind ; } - if (stringarg) nc = el_parse_from_string(&sa, stringarg) ; + if (stringarg) + { + nc = el_parse_from_string(&sa, stringarg) ; + switch (nc) + { + case -4: strerr_dief2x(100, "unmatched ", "}") ; + case -3: strerr_dief2x(100, "unmatched ", "{") ; + case -2: strerr_dief1x(100, "syntax error") ; + case -1: strerr_diefu1sys(111, "parse script") ; + case 0 : return 0 ; + } + } else { char buf[BUFFER_INSIZE] ; @@ -118,15 +129,14 @@ int main (int argc, char const *const *argv, char const *const *envp) buffer_init(&b, &fd_readv, fd, buf, BUFFER_INSIZE) ; nc = el_parse_from_buffer(&sa, &b) ; fd_close(fd) ; - } - - switch (nc) - { - case -4: strerr_dief2x(100, "unmatched ", "}") ; - case -3: strerr_dief2x(100, "unmatched ", "{") ; - case -2: strerr_dief1x(100, "syntax error") ; - case -1: strerr_diefu1sys(111, "parse script") ; - case 0 : return 0 ; + switch (nc) + { + case -4: strerr_dief4x(100, "unmatched ", "}", " in file ", dollar0) ; + case -3: strerr_dief4x(100, "unmatched ", "{", " in file ", dollar0) ; + case -2: strerr_dief3x(100, "syntax error", " in file ", dollar0) ; + case -1: strerr_diefu3sys(111, "parse script", " in file ", dollar0) ; + case 0 : return 0 ; + } } if (flagstrict >= 0) -- cgit v1.2.3