summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-02-02 01:20:49 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2021-02-02 01:20:49 +0000
commit631f809ce4a14ec6f1af5118b99adc514be7db60 (patch)
tree7c972271688b80c5924055b83981d2db9c2c7bce
parent0033d003591f6bcc36313c8a16e7048ac01ef94c (diff)
downloadexecline-631f809ce4a14ec6f1af5118b99adc514be7db60.tar.xz
Prepare for 2.8.0.0; change backtick options and default behaviour
-rw-r--r--INSTALL2
-rw-r--r--NEWS7
-rw-r--r--doc/backtick.html16
-rw-r--r--doc/index.html4
-rw-r--r--doc/upgrade.html9
-rw-r--r--package/info2
-rw-r--r--src/execline/backtick.c26
7 files changed, 42 insertions, 24 deletions
diff --git a/INSTALL b/INSTALL
index 6664c35..d6a98ad 100644
--- a/INSTALL
+++ b/INSTALL
@@ -6,7 +6,7 @@ Build Instructions
- A POSIX-compliant C development environment
- GNU make version 3.81 or later
- - skalibs version 2.10.0.1 or later: https://skarnet.org/software/skalibs/
+ - skalibs version 2.10.0.2 or later: https://skarnet.org/software/skalibs/
- Optional: nsss version 0.1.0.0 or later: https://skarnet.org/software/nsss/
This software will run on any operating system that implements
diff --git a/NEWS b/NEWS
index 5e59371..7d651a5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,12 @@
Changelog for execline.
+In 2.8.0.0
+----------
+
+ - backtick now propagates failure by default; its options have
+slightly different semantics.
+
+
In 2.7.0.1
----------
diff --git a/doc/backtick.html b/doc/backtick.html
index 91e963a..e5a889d 100644
--- a/doc/backtick.html
+++ b/doc/backtick.html
@@ -30,7 +30,7 @@ environment variable, then executes another program.
</p>
<pre>
- backtick [ -i | -I | -D <em>default</em> ] [ -N | -n ] [ -E | -e ] <em>variable</em> { <em>prog1...</em> } <em>prog2...</em>
+ backtick [ -i | -I | -d | -D <em>default</em> ] [ -N | -n ] [ -E | -e ] <em>variable</em> { <em>prog1...</em> } <em>prog2...</em>
</pre>
<ul>
@@ -63,15 +63,17 @@ nonzero:
</p>
<ul>
- <li> <tt>-i</tt>&nbsp;: backtick exits 1. </li>
- <li> <tt>-I</tt>&nbsp;: <em>variable</em> is <strong>removed</strong> from
+ <li> <tt>-i</tt>&nbsp;: backtick exits with an
+<a href="exitcodes.html">approximation</a> of <em>prog1</em>'s exit code,
+or 124 if <em>prog1</em> wrote a null character. This is the default. </li>
+ <li> <tt>-I</tt>: the value of <em>variable</em> is set to whatever
+the start of <em>prog1...</em>'s output is, up to the first null character,
+or to whatever <em>prog1...</em> wrote before crashing; chomping is applied
+if required; then execution proceeds. </li>
+ <li> <tt>-d</tt>&nbsp;: <em>variable</em> is <strong>removed</strong> from
the environment, and execution proceeds. </li>
<li> <tt>-D&nbsp;<em>default</em></tt>&nbsp;: the value of <em>variable</em>
is set to <em>default</em>, and execution proceeds. </li>
- <li> neither of those options: the value of <em>variable</em> is set to whatever
-the start of <em>prog1...</em>'s output is, up to the first null character,
-or to whatever <em>prog1...</em> wrote before crashing;
-then execution proceeds. </li>
</ul>
</body>
diff --git a/doc/index.html b/doc/index.html
index c708c6d..8222a48 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.10.0.1 or later. It's a build-time requirement. It's also a run-time
+2.10.0.2 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.7.0.1.tar.gz">2.7.0.1</a>. </li>
+ <li> The current released version of execline is <a href="execline-2.8.0.0.tar.gz">2.8.0.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 eac79a7..b30f6ac 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -18,6 +18,15 @@
<h1> What has changed in execline </h1>
+<h2> in 2.8.0.0 </h2>
+
+<ul>
+ <li> <a href="//skarnet.org/software/skalibs/">skalibs</a>
+dependency bumped to 2.10.0.2. </li>
+ <li> <a href="backtick.html">backtick</a> options have changed
+slightly, and now propagates subprocess failure by default. </li>
+</ul>
+
<h2> in 2.7.0.1 </h2>
<ul>
diff --git a/package/info b/package/info
index d134793..66a7627 100644
--- a/package/info
+++ b/package/info
@@ -1,4 +1,4 @@
package=execline
-version=2.7.0.1
+version=2.8.0.0
category=admin
package_macro_name=EXECLINE
diff --git a/src/execline/backtick.c b/src/execline/backtick.c
index 9394456..93d5828 100644
--- a/src/execline/backtick.c
+++ b/src/execline/backtick.c
@@ -22,20 +22,21 @@ int main (int argc, char const **argv, char const *const *envp)
stralloc value = STRALLOC_ZERO ;
char const *var ;
char const *val ;
- int insist = 0, chomp = 1, doimport = 0 ;
+ int insist = 2, chomp = 1, doimport = 0 ;
char const *def = 0 ;
PROG = "backtick" ;
for (;;)
{
- int opt = subgetopt_r(argc, argv, "iINnD:Ee", &localopt) ;
+ int opt = subgetopt_r(argc, argv, "iINndD:Ee", &localopt) ;
if (opt < 0) break ;
switch (opt)
{
case 'i' : insist = 2 ; break ;
- case 'I' : insist = 1 ; break ;
+ case 'I' : insist = 0 ; break ;
case 'N' : chomp = 0 ; break ;
case 'n' : chomp = 1 ; break ;
- case 'D' : def = localopt.arg ; break ;
+ case 'd' : insist = 1 ; def = 0 ; break ;
+ case 'D' : insist = 1 ; def = localopt.arg ; break ;
case 'E' : doimport = 1 ; break ;
case 'e' : doimport = 0 ; break ;
default : dieusage() ;
@@ -64,23 +65,22 @@ int main (int argc, char const **argv, char const *const *envp)
if (wait_status(fdwstat))
{
if (insist >= 2)
- if (WIFSIGNALED(fdwstat)) strerr_dief1x(111, "child process crashed") ;
- else strerr_dief1x(WEXITSTATUS(fdwstat), "child process exited non-zero") ;
- else if (insist) val = 0 ;
- else if (def) val = def ;
+ strerr_dief1x(wait_estatus(fdwstat), WIFSIGNALED(fdwstat) ? "child process crashed" : "child process exited non-zero") ;
+ else if (insist) val = def ;
}
else if (strlen(value.s) < value.len - 1)
{
if (insist >= 2)
- strerr_dief1x(1, "child process output contained a null character") ;
- else if (insist) val = 0 ;
- else if (def)
+ strerr_dief1x(124, "child process output contained a null character") ;
+ else if (insist)
{
val = def ;
- strerr_warnw2x("child process output contained a null character", " - using default instead") ;
+ strerr_warnw1x("child process output contained a null character") ;
}
+ else value.len = strlen(value.s) + 1 ;
}
- else if (chomp && (value.s[value.len - 2] == '\n'))
+ else insist = 0 ;
+ if (!insist && chomp && (value.s[value.len - 2] == '\n'))
value.s[--value.len - 1] = 0 ;
el_modif_and_exec(argv + argc1 + 1, var, val, doimport) ;
}