diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2026-03-09 19:03:37 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2026-03-09 19:03:37 +0000 |
| commit | 6c756905574a019df52ad865a81cf97b6e2b6c58 (patch) | |
| tree | 54bb9ff91422a6de7606c1a9be6c29e080d7d994 /src/libexecline | |
| parent | 26fa9d9d3fef9684e9e4d5cd0bcd4336fee8d749 (diff) | |
| download | execline-6c756905574a019df52ad865a81cf97b6e2b6c58.tar.gz | |
Fix wait command interaction with EXECLINE_STRICT
el_semicolon() hardcodes failure on EXECLINE_STRICT=2, but we
want to accept a no-block interface for wait, so write a separate
el_semicolon_nostrict() function and use it in wait.
Also use gol in wait, and prepare deprecation of quote chars
other than space and null (we can hardcode this np)
Diffstat (limited to 'src/libexecline')
| -rw-r--r-- | src/libexecline/deps-lib/execline | 1 | ||||
| -rw-r--r-- | src/libexecline/el_semicolon.c | 36 | ||||
| -rw-r--r-- | src/libexecline/el_semicolon_nostrict.c | 14 |
3 files changed, 31 insertions, 20 deletions
diff --git a/src/libexecline/deps-lib/execline b/src/libexecline/deps-lib/execline index d5888c0..86dabd2 100644 --- a/src/libexecline/deps-lib/execline +++ b/src/libexecline/deps-lib/execline @@ -10,6 +10,7 @@ el_parse_from_string.o el_popenv.o el_pushenv.o el_semicolon.o +el_semicolon_nostrict.o el_spawn0.o el_gspawn0.o el_substandrun.o diff --git a/src/libexecline/el_semicolon.c b/src/libexecline/el_semicolon.c index 735fe9a..dc6b938 100644 --- a/src/libexecline/el_semicolon.c +++ b/src/libexecline/el_semicolon.c @@ -1,35 +1,31 @@ /* ISC license. */ -#include <skalibs/env.h> #include <skalibs/strerr.h> #include <skalibs/types.h> + #include <execline/execline.h> int el_semicolon (char const **argv) { static unsigned int nblock = 0 ; - int argc1 = 0 ; + unsigned int strict = el_getstrict() ; nblock++ ; - for (;; argc1++, argv++) + unsigned int i = 0 ; + for (; argv[i] ; i++) { - char const *arg = *argv ; - if (!arg) return argc1 + 1 ; - if ((arg[0] == EXECLINE_BLOCK_END_CHAR) && (!EXECLINE_BLOCK_END_CHAR || !arg[1])) return argc1 ; - else if (arg[0] == EXECLINE_BLOCK_QUOTE_CHAR) ++*argv ; - else + if (!argv[i][0]) return i ; + else if (argv[i][0] == ' ') argv[i]++ ; + else if (strict) { - unsigned int strict = el_getstrict() ; - if (strict) - { - char fmt1[UINT_FMT] ; - char fmt2[UINT_FMT] ; - fmt1[uint_fmt(fmt1, nblock)] = 0 ; - fmt2[uint_fmt(fmt2, (unsigned int)argc1)] = 0 ; - if (strict >= 2) - strerr_dief6x(100, "unquoted argument ", arg, " at block ", fmt1, " position ", fmt2) ; - else - strerr_warnw6x("unquoted argument ", arg, " at block ", fmt1, " position ", fmt2) ; - } + char fmt1[UINT_FMT] ; + char fmt2[UINT_FMT] ; + fmt1[uint_fmt(fmt1, nblock)] = 0 ; + fmt2[uint_fmt(fmt2, i)] = 0 ; + if (strict >= 2) + strerr_dief6x(100, "unquoted argument ", argv[i], " at block ", fmt1, " position ", fmt2) ; + else + strerr_warnw6x("unquoted argument ", argv[i], " at block ", fmt1, " position ", fmt2) ; } } + return i + 1 ; } diff --git a/src/libexecline/el_semicolon_nostrict.c b/src/libexecline/el_semicolon_nostrict.c new file mode 100644 index 0000000..8fb770c --- /dev/null +++ b/src/libexecline/el_semicolon_nostrict.c @@ -0,0 +1,14 @@ +/* ISC license. */ + +#include <execline/execline.h> + +unsigned int el_semicolon_nostrict (char const **argv) +{ + unsigned int i = 0 ; + for (; argv[i] ; i++) + { + if (!argv[i][0]) return i ; + else if (argv[i][0] == ' ') argv[i]++ ; + } + return i + 1 ; +} |
