diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/execline/deps-exe/fdswap | 1 | ||||
-rw-r--r-- | src/execline/fdswap.c | 19 | ||||
-rw-r--r-- | src/execline/multisubstitute.c | 5 |
3 files changed, 21 insertions, 4 deletions
diff --git a/src/execline/deps-exe/fdswap b/src/execline/deps-exe/fdswap new file mode 100644 index 0000000..e7187fe --- /dev/null +++ b/src/execline/deps-exe/fdswap @@ -0,0 +1 @@ +-lskarnet diff --git a/src/execline/fdswap.c b/src/execline/fdswap.c new file mode 100644 index 0000000..13ac98b --- /dev/null +++ b/src/execline/fdswap.c @@ -0,0 +1,19 @@ +/* ISC license. */ + +#include <unistd.h> +#include <skalibs/uint.h> +#include <skalibs/strerr2.h> +#include <skalibs/djbunix.h> + +#define USAGE "fdswap fd1 fd2 prog..." + +int main (int argc, char const *const *argv, char const *const *envp) +{ + unsigned int fd1, fd2 ; + PROG = "fdswap" ; + if ((argc < 4) || !uint0_scan(argv[1], &fd1) || !uint0_scan(argv[2], &fd2)) + strerr_dieusage(100, USAGE) ; + if (fd_move2(fd1, fd2, fd2, fd1) < 0) strerr_diefu1sys(111, "swap fds") ; + pathexec_run(argv[3], argv+3, envp) ; + strerr_dieexec(111, argv[3]) ; +} diff --git a/src/execline/multisubstitute.c b/src/execline/multisubstitute.c index acee42f..d7fbb4e 100644 --- a/src/execline/multisubstitute.c +++ b/src/execline/multisubstitute.c @@ -18,7 +18,7 @@ static char const *const commands[8] = 0 } ; -static exlsnfunc_t *const functions[8] = +static exlsnfunc_t_ref const functions[8] = { &exlsn_define, &exlsn_importas, @@ -36,12 +36,10 @@ int main (int argc, char const **argv, char const *const *envp) PROG = "multisubstitute" ; if (!--argc) strerr_dieusage(100, USAGE) ; - /* Read a block containing directives */ argc1 = el_semicolon(++argv) ; if (argc1 >= argc) strerr_dief1x(100, "unterminated block") ; if (argc1 + 1 == argc) strerr_dieusage(100, USAGE) ; - /* Parse args and update the substitution info */ while (argc1) { int n ; @@ -59,6 +57,5 @@ int main (int argc, char const **argv, char const *const *envp) argv += n ; argc1 -= n ; argc -= n ; } - /* Perform the substitution and exec */ el_substandrun(argc-1, argv+1, envp, &info) ; } |