summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--COPYING2
-rw-r--r--NEWS2
-rw-r--r--doc/runblock.html7
-rw-r--r--doc/upgrade.html2
-rw-r--r--src/execline/runblock.c17
5 files changed, 23 insertions, 7 deletions
diff --git a/COPYING b/COPYING
index f019bc7..b956149 100644
--- a/COPYING
+++ b/COPYING
@@ -1,4 +1,4 @@
-Copyright (c) 2011-2019 Laurent Bercot <ska-skaware@skarnet.org>
+Copyright (c) 2011-2020 Laurent Bercot <ska-skaware@skarnet.org>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/NEWS b/NEWS
index 6e42862..fd49c8f 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ In 2.6.0.0
- The dollarat program now has its conflicting -0 and -d options
handled in the conventional way, with rightmost priority.
+ - runblock now accepts a command line prefix, given as runblock's
+own command line.
- New binary: posix-umask.
- cd renamed to execline-cd, umask renamed to execline-umask
- With --enable-pedantic-posix, umask is a symbolic link to
diff --git a/doc/runblock.html b/doc/runblock.html
index 476f801..f090f85 100644
--- a/doc/runblock.html
+++ b/doc/runblock.html
@@ -23,12 +23,14 @@
in the execline language. It can only be used inside an execline
script. If the script has been given blocks as arguments, <tt>runblock</tt>
allows you to execute one of the blocks individually.
+It also allows you to give those blocks as a set of arguments to
+another command.
</p>
<h2> Interface </h2>
<pre>
- runblock [ -P ] [ -n <em>argshift</em> ] [ -r ] <em>n</em>
+ runblock [ -P ] [ -n <em>argshift</em> ] [ -r ] <em>n</em> <em>cmd...</em>
</pre>
<ul>
@@ -41,6 +43,9 @@ arguments <em>and</em> blocks. </li>
<em>n</em> blocks and execs into the remaining arguments. </li>
<li> Else it skips <em>n</em>-1 blocks and execs into the <em>n</em>th
one. </li>
+ <li> If <em>cmd...<em> is not empty, then instead of directly executing the
+block or the remainder, <tt>runblock</tt> <em>appends</em> the selected
+set of arguments to the <em>cmd...</em> command line. </li>
<li> Normally <tt>runblock</tt> <a href="el_pushenv.html#pop">pops</a>
its environment frame before executing. If the <tt>-P</tt> option has
been given, it <em>does not</em> pop. </li>
diff --git a/doc/upgrade.html b/doc/upgrade.html
index e286098..e049628 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -23,6 +23,8 @@
<ul>
<li> <a href="dollarat.html">dollarat</a> now has its <tt>-0</tt> and <tt>-d</tt>
priority unified. (Rightmost priority.) </li>
+ <li> <a href="runblock.html">runblock</a> now accepts a command line prefix,
+given as runblock's own command line. </li>
<li> New binary: <a href="posix-umask.html">posix-umask</a>. </li>
<li> <tt>cd</tt> has been renamed <a href="execline-cd.html">execline-cd</a>. </li>
<li> <tt>umask</tt> has been renamed <a href="execline-umask.html">execline-umask</a>. </li>
diff --git a/src/execline/runblock.c b/src/execline/runblock.c
index ab81bb3..fdba5af 100644
--- a/src/execline/runblock.c
+++ b/src/execline/runblock.c
@@ -10,7 +10,7 @@
#include <skalibs/skamisc.h>
#include <execline/execline.h>
-#define USAGE "runblock [ -P ] [ -n argshift ] [ -r ] n"
+#define USAGE "runblock [ -P ] [ -n argshift ] [ -r ] n cmd..."
#define dieusage() strerr_dieusage(100, USAGE)
int main (int argc, char const *const *argv, char const *const *envp)
@@ -37,8 +37,8 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
argc -= l.ind ; argv += l.ind ;
}
- if (argc != 1) dieusage() ;
- if (!uint0_scan(argv[0], &n) || (!n && !flagr)) dieusage() ;
+ if (!argc--) dieusage() ;
+ if (!uint0_scan(*argv++, &n) || (!n && !flagr)) dieusage() ;
{
char const *x = env_get2(envp, "#") ;
@@ -76,11 +76,18 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
}
+ /* First put args, if any, into v */
+
+ if (!genalloc_ready(char const *, &v, argc))
+ strerr_diefu1sys(111, "genalloc_ready") ;
+ for (unsigned int i = 0 ; i < (unsigned int)argc ; i++)
+ genalloc_append(char const *, &v, argv + i) ;
+
if (flagr) /* put remainder envvars into v */
{
if (++m > sharp) return 0 ;
- if (!genalloc_ready(char const *, &v, sharp - m + 2))
- strerr_diefu1sys(111, "genalloc_ready") ;
+ if (!genalloc_readyplus(char const *, &v, sharp - m + 2))
+ strerr_diefu1sys(111, "genalloc_readyplus") ;
for (; m <= sharp ; m++)
{
char const *x ;