diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2022-02-27 02:52:20 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2022-02-27 02:52:20 +0000 |
commit | a80a1304ff86b8cf493265696d517aea2cf7a703 (patch) | |
tree | 8368824fc484acc7fdb68b281f56c1e6966d46b3 | |
parent | 35c2366d1f09bb2805e3edcdff9966f7d40d14b0 (diff) | |
download | s6-portable-utils-a80a1304ff86b8cf493265696d517aea2cf7a703.tar.xz |
Prepare for 2.2.4.0; add -N option to s6-dumpenv
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r-- | INSTALL | 2 | ||||
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | doc/index.html | 4 | ||||
-rw-r--r-- | doc/s6-dumpenv.html | 8 | ||||
-rw-r--r-- | doc/upgrade.html | 7 | ||||
-rw-r--r-- | package/info | 2 | ||||
-rw-r--r-- | src/skaembutils/s6-dumpenv.c | 17 |
7 files changed, 37 insertions, 9 deletions
@@ -6,7 +6,7 @@ Build Instructions - A POSIX-compliant C development environment - GNU make version 3.81 or later - - skalibs version 2.11.1.0 or later: https://skarnet.org/software/skalibs/ + - skalibs version 2.11.2.0 or later: https://skarnet.org/software/skalibs/ This software will run on any operating system that implements POSIX.1-2008, available at: @@ -1,5 +1,11 @@ Changelog for s6-portable-utils. +In 2.2.4.0 +---------- + + - New -N option to s6-dumpenv, for chomping retrieval. + + In 2.2.3.4 ---------- diff --git a/doc/index.html b/doc/index.html index 96036ca..d4530f1 100644 --- a/doc/index.html +++ b/doc/index.html @@ -74,7 +74,7 @@ on the wrong page. I apologize for the confusion. <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.11.1.0 or later. It's a build-time requirement. It's also a run-time +2.11.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> @@ -90,7 +90,7 @@ library. </li> <ul> <li> The current released version of s6-portable-utils is -<a href="s6-portable-utils-2.2.3.4.tar.gz">2.2.3.4</a>. </li> +<a href="s6-portable-utils-2.2.4.0.tar.gz">2.2.4.0</a>. </li> <li> Alternatively, you can checkout a copy of the <a href="//git.skarnet.org/cgi-bin/cgit.cgi/s6-portable-utils/">s6-portable-utils git repository</a>: diff --git a/doc/s6-dumpenv.html b/doc/s6-dumpenv.html index 1c89ddc..6400d47 100644 --- a/doc/s6-dumpenv.html +++ b/doc/s6-dumpenv.html @@ -25,7 +25,7 @@ <h2> Interface </h2> <pre> - s6-dumpenv [ -m <em>mode</em> ] <em>dir</em> + s6-dumpenv [ -N | -n ] [ -m <em>mode</em> ] <em>dir</em> </pre> <ul> @@ -40,6 +40,12 @@ that it has, it creates a file <em>dir</em>/<em>x</em> containing <h2> Options </h2> <ul> + <li> <tt>-N</tt> : chomp. Write the environment variables with an +extra newline at the end, so the environment can be retrieved via +<tt>s6-envdir -Lf <em>dir</em></tt>. </li> + <li> <tt>-n</tt> : Write the environment variables as is; the +environment will be retrieved via <tt>s6-envdir -Lfn <em>dir</em></tt>. +This is the default. </li> <li> <tt>-m</tt> <em>mode</em> : create <em>dir</em> with mode <em>mode</em> if it doesn't exist yet. Default is 0755. </li> </ul> diff --git a/doc/upgrade.html b/doc/upgrade.html index 8193a1e..24077e3 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -18,6 +18,13 @@ <h1> What has changed in s6-portable-utils </h1> +<h2> in 2.2.4.0 </h2> + +<ul> + <li> <a href="//skarnet.org/software/skalibs/">skalibs</a> +dependency bumped to 2.11.2.0. </li> +</ul> + <h2> in 2.2.3.4 </h2> <ul> diff --git a/package/info b/package/info index ffa7f48..e55f97b 100644 --- a/package/info +++ b/package/info @@ -1,4 +1,4 @@ package=s6-portable-utils -version=2.2.3.4 +version=2.2.4.0 category=admin package_macro_name=S6_PORTABLE_UTILS diff --git a/src/skaembutils/s6-dumpenv.c b/src/skaembutils/s6-dumpenv.c index 87950d0..53d9f84 100644 --- a/src/skaembutils/s6-dumpenv.c +++ b/src/skaembutils/s6-dumpenv.c @@ -3,29 +3,33 @@ #include <string.h> #include <sys/stat.h> #include <errno.h> +#include <sys/uio.h> + #include <skalibs/types.h> #include <skalibs/bytestr.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> -#define USAGE "s6-dumpenv [ -m mode ] envdir" +#define USAGE "s6-dumpenv [ -N | -n ] [ -m mode ] envdir" #define dieusage() strerr_dieusage(100, USAGE) int main (int argc, char const *const *argv, char const *const *envp) { unsigned int mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH ; + int chomp = 0 ; size_t dirlen ; - PROG = "s6-dumpenv" ; { subgetopt l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "m:", &l) ; + int opt = subgetopt_r(argc, argv, "nNm:", &l) ; if (opt == -1) break ; switch (opt) { + case 'n' : chomp = 0 ; break ; + case 'N' : chomp = 1 ; break ; case 'm' : if (!uint0_oscan(l.arg, &mode)) dieusage() ; break ; default : dieusage() ; } @@ -51,12 +55,17 @@ int main (int argc, char const *const *argv, char const *const *envp) for (; *envp ; envp++) { size_t varlen = str_chr(*envp, '=') ; + struct iovec const v[2] = + { + { .iov_base = (char *)*envp + varlen + 1, .iov_len = strlen(*envp + varlen + 1) }, + { .iov_base = "\n", .iov_len = 1 } + } ; char fn[dirlen + varlen + 2] ; memcpy(fn, argv[0], dirlen) ; fn[dirlen] = '/' ; memcpy(fn + dirlen + 1, *envp, varlen) ; fn[dirlen + 1 + varlen] = 0 ; - if (!openwritenclose_suffix(fn, *envp + varlen + 1, strlen(*envp + varlen + 1), "=.tmp")) + if (!openwritevnclose_suffix(fn, v, 1 + chomp, "=.tmp")) strerr_diefu2sys(111, "open ", fn) ; } return 0 ; |