diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2024-05-27 16:35:40 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2024-05-27 16:35:40 +0000 |
commit | 793dc09daa859b94c69b2f6d9e45e4abf0300069 (patch) | |
tree | ab9a8d3b6cb21409db561e30f44b0ac0fa6aec06 | |
parent | 0f17d658e63bbe06d4f278f81e255446dd30489d (diff) | |
download | execline-793dc09daa859b94c69b2f6d9e45e4abf0300069.tar.xz |
Prepare for 2.9.6.0, add elglob -d
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r-- | INSTALL | 2 | ||||
-rw-r--r-- | NEWS | 8 | ||||
-rw-r--r-- | doc/elglob.html | 12 | ||||
-rw-r--r-- | doc/index.html | 4 | ||||
-rw-r--r-- | doc/upgrade.html | 9 | ||||
-rw-r--r-- | package/info | 2 | ||||
-rw-r--r-- | src/execline/elglob.c | 3 | ||||
-rw-r--r-- | src/execline/multisubstitute.c | 2 | ||||
-rw-r--r-- | src/libexecline/exlsn_elglob.c | 28 |
9 files changed, 55 insertions, 15 deletions
@@ -6,7 +6,7 @@ Build Instructions - A POSIX-compliant C development environment - GNU make version 3.81 or later - - skalibs version 2.14.1.1 or later: https://skarnet.org/software/skalibs/ + - skalibs version 2.14.2.0 or later: https://skarnet.org/software/skalibs/ - Optional: nsss version 0.2.0.4 or later: https://skarnet.org/software/nsss/ This software will run on any operating system that implements @@ -1,5 +1,13 @@ Changelog for execline. +In 2.9.6.0 +---------- + + - elglob can now provide a single word, where the results of the +globbing are separated by a given delimiter (or encoded into a +netstring). + + In 2.9.5.1 ---------- diff --git a/doc/elglob.html b/doc/elglob.html index 0870d2d..e9e73b1 100644 --- a/doc/elglob.html +++ b/doc/elglob.html @@ -26,7 +26,7 @@ another program. <h2> Interface </h2> <pre> - elglob [ -v ] [ -w ] [ -s ] [ -m ] [ -e ] [ -0 ] <em>variable</em> <em>pattern</em> <em>prog...</em> + elglob [ -v ] [ -w ] [ -s ] [ -m ] [ -e ] [ -0 ] [ -n ] [ -d <em>delim</em> ] <em>variable</em> <em>pattern</em> <em>prog...</em> </pre> <ul> @@ -63,6 +63,16 @@ it. </li> matches nothing, it will be substituted as is (verbatim in one word). With this option, if <em>pattern</em> matches nothing, it will be properly substituted as zero word. </li> + <li> <tt>-n</tt> : chomp. Don't add an ending delimiter at the end +of the word. Only valid with the <tt>-d</tt> option, see below. </li> + <li> <tt>-d <em>delim</em></tt> : do not split the value. +Instead, make it one word, where the result of the globbing are separated +by the first character of <em>delim</em>. If the <tt>-n</tt> option is +not given, the first character of <em>delim</em> also appears after the +last result. If <em>delim</em> is the empty string, the values are +encoded as a sequence of netstrings into a single word, (and you can +later separate the words with e.g. +<a href="define.html">define -s</a>). </li> </ul> </body> diff --git a/doc/index.html b/doc/index.html index 74f83f3..5680b96 100644 --- a/doc/index.html +++ b/doc/index.html @@ -51,7 +51,7 @@ shell's syntax, and has no security issues. <li> A POSIX-compliant system with a standard C development environment </li> <li> GNU make, version 3.81 or later. </li> <li> <a href="//skarnet.org/software/skalibs/">skalibs</a> version -2.14.1.1 or later. It's a build-time requirement. It's also a run-time +2.14.2.0 or later. It's a build-time requirement. It's also a run-time requirement if you link against the shared version of the skalibs library. </li> </ul> @@ -77,7 +77,7 @@ want nsswitch-like functionality: <h3> Download </h3> <ul> - <li> The current released version of execline is <a href="execline-2.9.5.1.tar.gz">2.9.5.1</a>. </li> + <li> The current released version of execline is <a href="execline-2.9.6.0.tar.gz">2.9.6.0</a>. </li> <li> Alternatively, you can checkout a copy of the <a href="//git.skarnet.org/cgi-bin/cgit.cgi/execline/">execline git repository</a>: diff --git a/doc/upgrade.html b/doc/upgrade.html index 927db65..17da599 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -18,6 +18,15 @@ <h1> What has changed in execline </h1> +<h2> in 2.9.6.0 </h2> + +<ul> + <li> <a href="//skarnet.org/software/skalibs/">skalibs</a> +dependency bumped to 2.14.2.0. </li> + <li> <a href="elglob.html">elglob</a> now has an option to provide its +results as one word (including the possibility of netstring encoding). </li> +</ul> + <h2> in 2.9.5.1 </h2> <ul> diff --git a/package/info b/package/info index dc71495..38faf6f 100644 --- a/package/info +++ b/package/info @@ -1,4 +1,4 @@ package=execline -version=2.9.5.1 +version=2.9.6.0 category=admin package_macro_name=EXECLINE diff --git a/src/execline/elglob.c b/src/execline/elglob.c index 654e899..3e13e32 100644 --- a/src/execline/elglob.c +++ b/src/execline/elglob.c @@ -1,9 +1,10 @@ /* ISC license. */ #include <skalibs/strerr.h> + #include "exlsn.h" -#define USAGE "elglob [ -v ] [ -w ] [ -s ] [ -m ] [ -e ] [ -0 ] key pattern prog..." +#define USAGE "elglob [ -v ] [ -w ] [ -s ] [ -m ] [ -e ] [ -0 ] [ -n ] [ -d delim ] key pattern prog..." int main (int argc, char const **argv, char const *const *envp) { diff --git a/src/execline/multisubstitute.c b/src/execline/multisubstitute.c index da4e222..be78740 100644 --- a/src/execline/multisubstitute.c +++ b/src/execline/multisubstitute.c @@ -1,7 +1,9 @@ /* ISC license. */ #include <string.h> + #include <skalibs/strerr.h> + #include <execline/execline.h> #include "exlsn.h" diff --git a/src/libexecline/exlsn_elglob.c b/src/libexecline/exlsn_elglob.c index c526e41..a5b66f3 100644 --- a/src/libexecline/exlsn_elglob.c +++ b/src/libexecline/exlsn_elglob.c @@ -1,12 +1,16 @@ /* ISC license. */ +#include <sys/uio.h> #include <errno.h> #include <glob.h> #include <string.h> + #include <skalibs/sgetopt.h> #include <skalibs/strerr.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> +#include <skalibs/netstring.h> + #include <execline/execline.h> #include "exlsn.h" @@ -20,16 +24,15 @@ static int elgloberrfunc (char const *s, int e) int exlsn_elglob (int argc, char const **argv, char const *const *envp, exlsn_t *info) { glob_t pglob ; - subgetopt localopt = SUBGETOPT_ZERO ; - elsubst_t blah ; + elsubst_t blah = { .var = info->vars.len, .value = info->values.len, .n = 1 } ; int flags = GLOB_NOSORT | GLOB_NOCHECK ; - unsigned int i = 0 ; int verbose = 0 ; - blah.var = info->vars.len ; - blah.value = info->values.len ; + int dochomp = 0 ; + char const *delim = 0 ; + subgetopt localopt = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "vwsme0", &localopt) ; + int opt = subgetopt_r(argc, argv, "vwsme0nd:", &localopt) ; if (opt < 0) break ; switch (opt) { @@ -39,10 +42,13 @@ int exlsn_elglob (int argc, char const **argv, char const *const *envp, exlsn_t case 'm' : flags |= GLOB_MARK ; break ; case 'e' : flags |= GLOB_NOESCAPE ; break ; case '0' : flags &= ~GLOB_NOCHECK ; break ; + case 'n' : dochomp = 1 ; break ; + case 'd' : delim = localopt.arg ; break ; default : return -3 ; } } argc -= localopt.ind ; argv += localopt.ind ; + if (!delim) delim = "" ; else if (!*delim) delim = 0 ; if (argc < 2) return -3 ; if (!*argv[0] || el_vardupl(argv[0], info->vars.s, info->vars.len)) return -2 ; @@ -60,11 +66,15 @@ int exlsn_elglob (int argc, char const **argv, char const *const *envp, exlsn_t } default: goto err ; } - for ( ; i < (unsigned int)pglob.gl_pathc ; i++) - if (!stralloc_catb(&info->values, pglob.gl_pathv[i], strlen(pglob.gl_pathv[i]) + 1)) + for (size_t i = 0 ; i < pglob.gl_pathc ; i++) + if (delim ? !stralloc_cats(&info->values, pglob.gl_pathv[i]) || !stralloc_catb(&info->values, delim, 1) : + !netstring_appendb(&info->values, pglob.gl_pathv[i], strlen(pglob.gl_pathv[i]))) goto globerr ; - blah.n = pglob.gl_pathc ; + if (delim && *delim && dochomp) info->values.len-- ; + if (delim && !*delim) blah.n = pglob.gl_pathc ; + else if (!stralloc_0(&info->values)) goto globerr ; globfree(&pglob) ; + if (!genalloc_append(elsubst_t, &info->data, &blah)) goto err ; (void)envp ; return localopt.ind + 2 ; |