diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/execline/backtick.c | 7 | ||||
-rw-r--r-- | src/execline/define.c | 2 | ||||
-rw-r--r-- | src/execline/forbacktickx.c | 16 | ||||
-rw-r--r-- | src/execline/forstdin.c | 12 | ||||
-rw-r--r-- | src/execline/forx.c | 3 | ||||
-rw-r--r-- | src/execline/ifthenelse.c | 2 | ||||
-rw-r--r-- | src/execline/importas.c | 2 | ||||
-rw-r--r-- | src/execline/multidefine.c | 2 | ||||
-rw-r--r-- | src/execline/redirfd.c | 6 | ||||
-rw-r--r-- | src/execline/tryexec.c | 2 | ||||
-rw-r--r-- | src/execline/withstdinas.c | 7 | ||||
-rw-r--r-- | src/libexecline/exlsn_define.c | 3 | ||||
-rw-r--r-- | src/libexecline/exlsn_importas.c | 3 | ||||
-rw-r--r-- | src/libexecline/exlsn_multidefine.c | 3 |
14 files changed, 37 insertions, 33 deletions
diff --git a/src/execline/backtick.c b/src/execline/backtick.c index 94421b1..ea2399f 100644 --- a/src/execline/backtick.c +++ b/src/execline/backtick.c @@ -10,7 +10,7 @@ #include <skalibs/djbunix.h> #include <execline/execline.h> -#define USAGE "backtick [ -i | -I | -D default ] [ -n ] var { prog... } remainder..." +#define USAGE "backtick [ -i | -I | -D default ] [ -N | -n ] var { prog... } remainder..." #define dieusage() strerr_dieusage(100, USAGE) int main (int argc, char const **argv, char const *const *envp) @@ -20,17 +20,18 @@ int main (int argc, char const **argv, char const *const *envp) int argc1, fdwstat ; stralloc modif = STRALLOC_ZERO ; size_t modifstart ; - int insist = 0, chomp = 0 ; + int insist = 0, chomp = 1 ; char const *def = 0 ; PROG = "backtick" ; for (;;) { - int opt = subgetopt_r(argc, argv, "iInD:", &localopt) ; + int opt = subgetopt_r(argc, argv, "iINnD:", &localopt) ; if (opt < 0) break ; switch (opt) { case 'i' : insist = 2 ; break ; case 'I' : insist = 1 ; break ; + case 'N' : chomp = 0 ; break ; case 'n' : chomp = 1 ; break ; case 'D' : def = localopt.arg ; break ; default : dieusage() ; diff --git a/src/execline/define.c b/src/execline/define.c index f87c531..52ee67d 100644 --- a/src/execline/define.c +++ b/src/execline/define.c @@ -3,7 +3,7 @@ #include <skalibs/strerr2.h> #include "exlsn.h" -#define USAGE "define [ -n ] [ -s ] [ -C | -c ] [ -d delim ] key value prog..." +#define USAGE "define [ -N | -n ] [ -s ] [ -C | -c ] [ -d delim ] key value prog..." int main (int argc, char const **argv, char const *const *envp) { diff --git a/src/execline/forbacktickx.c b/src/execline/forbacktickx.c index 8b31d92..3e07442 100644 --- a/src/execline/forbacktickx.c +++ b/src/execline/forbacktickx.c @@ -10,27 +10,25 @@ #include <execline/config.h> #include <execline/execline.h> -#define USAGE "forbacktickx [ -p | -o okcode,okcode,... | -x breakcode,breakcode,... ] [ -n ] [ -C | -c ] [ -0 | -d delim ] var { backtickcmd... } command..." +#define USAGE "forbacktickx [ -p | -o okcode,okcode,... | -x breakcode,breakcode,... ] [ -N | -n ] [ -C | -c ] [ -0 | -d delim ] var { backtickcmd... } command..." #define dieusage() strerr_dieusage(100, USAGE) -#define DELIM_DEFAULT " \n\r\t" - int main (int argc, char const *const *argv, char const *const *envp) { - char const *delim = DELIM_DEFAULT ; + char const *delim = "\n" ; char const *codes = 0 ; - int crunch = 0, chomp = 0, not = 1, par = 0 ; + int crunch = 0, chomp = 1, not = 1, par = 0 ; PROG = "forbacktickx" ; { subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "epnCc0d:o:x:", &l) ; + int opt = subgetopt_r(argc, argv, "pNnCc0d:o:x:", &l) ; if (opt == -1) break ; switch (opt) { - case 'e' : break ; /* compat */ case 'p' : par = 1 ; break ; + case 'N' : chomp = 0 ; break ; case 'n' : chomp = 1 ; break ; case 'C' : crunch = 1 ; break ; case 'c' : crunch = 0 ; break ; @@ -82,10 +80,10 @@ int main (int argc, char const *const *argv, char const *const *envp) newargv[m++] = "!" ; newargv[m++] = EXECLINE_BINPREFIX "forstdin" ; if (par) newargv[m++] = "-p" ; - if (chomp) newargv[m++] = "-n" ; + newargv[m++] = chomp ? "-n" : "-N" ; if (crunch) newargv[m++] = "-C" ; if (!delim) newargv[m++] = "-0" ; - else if (strcmp(delim, DELIM_DEFAULT)) + else if (strcmp(delim, "\n")) { newargv[m++] = "-d" ; newargv[m++] = delim ; diff --git a/src/execline/forstdin.c b/src/execline/forstdin.c index b907ef2..d57406a 100644 --- a/src/execline/forstdin.c +++ b/src/execline/forstdin.c @@ -15,10 +15,11 @@ #include <skalibs/djbunix.h> #include <skalibs/skamisc.h> #include <skalibs/netstring.h> + #include <execline/config.h> #include <execline/execline.h> -#define USAGE "forstdin [ -p | -o okcode,okcode,... | -x breakcode,breakcode,... ] [ -n ] [ -C | -c ] [ -0 | -d delim ] var command..." +#define USAGE "forstdin [ -p | -o okcode,okcode,... | -x breakcode,breakcode,... ] [ -N | -n ] [ -C | -c ] [ -0 | -d delim ] var command..." #define dieusage() strerr_dieusage(100, USAGE) static genalloc pids = GENALLOC_ZERO ; /* pid_t */ @@ -51,13 +52,13 @@ int main (int argc, char const **argv, char const *const *envp) size_t delimlen = 1 ; size_t nbc = 0 ; unsigned short okcodes[256] ; - int crunch = 0, chomp = 0, not = 1, eofcode = 1 ; + int crunch = 0, chomp = 1, not = 1, eofcode = 1 ; PROG = "forstdin" ; { subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "pnCc0d:o:x:", &l) ; + int opt = subgetopt_r(argc, argv, "pNnCc0d:o:x:", &l) ; if (opt == -1) break ; switch (opt) { @@ -67,6 +68,7 @@ int main (int argc, char const **argv, char const *const *envp) strerr_diefu1sys(111, "genalloc_ready") ; break ; } + case 'N' : chomp = 0 ; break ; case 'n' : chomp = 1 ; break ; case 'C' : crunch = 1 ; break ; case 'c' : crunch = 0 ; break ; @@ -113,7 +115,8 @@ int main (int argc, char const **argv, char const *const *envp) if (errno != EPIPE) strerr_diefu1sys(111, "skagetlnsep") ; if (chomp) break ; } - else modif.len-- ; + if (crunch && modif.len == modifstart + 1) continue ; + if (chomp) modif.len-- ; } else { @@ -125,7 +128,6 @@ int main (int argc, char const **argv, char const *const *envp) } } eofcode = 0 ; - if (crunch && modif.len == modifstart) continue ; if (!stralloc_0(&modif)) strerr_diefu1sys(111, "stralloc_0") ; if (!env_merge(newenv, envlen+2, envp, envlen, modif.s, modif.len)) strerr_diefu1sys(111, "merge environment") ; diff --git a/src/execline/forx.c b/src/execline/forx.c index 06e6b39..8312704 100644 --- a/src/execline/forx.c +++ b/src/execline/forx.c @@ -53,11 +53,10 @@ int main (int argc, char const **argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "epo:x:", &l) ; + int opt = subgetopt_r(argc, argv, "po:x:", &l) ; if (opt == -1) break ; switch (opt) { - case 'e' : break ; /* compat */ case 'p' : flagpar = 1 ; break ; case 'o' : not = 0 ; diff --git a/src/execline/ifthenelse.c b/src/execline/ifthenelse.c index 86dbfe7..f0d75f9 100644 --- a/src/execline/ifthenelse.c +++ b/src/execline/ifthenelse.c @@ -59,7 +59,7 @@ int main (int argc, char const **argv, char const *const *envp) argv += argc2 + 1 ; argc2 = argc3 ; } - if (magicscope) /* undocumented voodoo - dangerous and powerful */ + if (magicscope) /* undocumented on purpose: powerful but dangerous */ { unsigned int i = 0 ; for (; remainder[i] ; i++) argv[argc2+i] = remainder[i] ; diff --git a/src/execline/importas.c b/src/execline/importas.c index 4011c83..bf20c64 100644 --- a/src/execline/importas.c +++ b/src/execline/importas.c @@ -3,7 +3,7 @@ #include <skalibs/strerr2.h> #include "exlsn.h" -#define USAGE "importas [ -i | -D default ] [ -u ] [ -n ] [ -s ] [ -C | -c ] [ -d delim ] key var prog..." +#define USAGE "importas [ -i | -D default ] [ -u ] [ -N | -n ] [ -s ] [ -C | -c ] [ -d delim ] key var prog..." int main (int argc, char const **argv, char const *const *envp) { diff --git a/src/execline/multidefine.c b/src/execline/multidefine.c index 9665418..b5685f5 100644 --- a/src/execline/multidefine.c +++ b/src/execline/multidefine.c @@ -3,7 +3,7 @@ #include <skalibs/strerr2.h> #include "exlsn.h" -#define USAGE "multidefine [ -0 ] [ -r ] [ -n ] [ -C | -c ] [ -d delim ] value { vars... } prog..." +#define USAGE "multidefine [ -0 ] [ -r ] [ -N | -n ] [ -C | -c ] [ -d delim ] value { vars... } prog..." int main (int argc, char const **argv, char const *const *envp) { diff --git a/src/execline/redirfd.c b/src/execline/redirfd.c index 93e1582..a34eaf7 100644 --- a/src/execline/redirfd.c +++ b/src/execline/redirfd.c @@ -2,12 +2,13 @@ #include <fcntl.h> #include <errno.h> + #include <skalibs/sgetopt.h> #include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> -#define USAGE "redirfd -[ r | w | u | a | c | x ] [ -n ] [ -b ] fd file prog..." +#define USAGE "redirfd -[ r | w | u | a | x ] [ -n ] [ -b ] fd file prog..." #define dieusage() strerr_dieusage(100, USAGE) int main (int argc, char const *const *argv, char const *const *envp) @@ -21,7 +22,7 @@ int main (int argc, char const *const *argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "rwuacxnb", &l) ; + int opt = subgetopt_r(argc, argv, "rwuaxnb", &l) ; if (opt == -1) break ; switch (opt) { @@ -29,7 +30,6 @@ int main (int argc, char const *const *argv, char const *const *envp) case 'w' : what = O_WRONLY ; flags |= O_CREAT|O_TRUNC ; flags &= ~(O_APPEND|O_EXCL) ; break ; case 'u' : what = O_RDWR ; flags &= ~(O_APPEND|O_CREAT|O_TRUNC|O_EXCL) ; break ; case 'a' : what = O_WRONLY ; flags |= O_CREAT|O_APPEND ; flags &= ~(O_TRUNC|O_EXCL) ; break ; - case 'c' : what = O_WRONLY ; flags |= O_APPEND ; flags &= ~(O_CREAT|O_TRUNC|O_EXCL) ; break ; case 'x' : what = O_WRONLY ; flags |= O_CREAT|O_EXCL ; flags &= ~(O_APPEND|O_TRUNC) ; break ; case 'n' : flags |= O_NONBLOCK ; break ; case 'b' : changemode = 1 ; break ; diff --git a/src/execline/tryexec.c b/src/execline/tryexec.c index 0b1ca87..f35312f 100644 --- a/src/execline/tryexec.c +++ b/src/execline/tryexec.c @@ -6,7 +6,7 @@ #include <skalibs/djbunix.h> #include <execline/execline.h> -#define USAGE "tryexec [ -n ] [ -c ] [ -l ] [ -a argv0 ] { command... }" +#define USAGE "tryexec [ -n ] [ -c ] [ -l ] [ -a argv0 ] { command... } remainder..." int main (int argc, char const **argv, char const *const *envp) { diff --git a/src/execline/withstdinas.c b/src/execline/withstdinas.c index 1118fa3..2dfcdf4 100644 --- a/src/execline/withstdinas.c +++ b/src/execline/withstdinas.c @@ -9,7 +9,7 @@ #include <skalibs/env.h> #include <skalibs/djbunix.h> -#define USAGE "withstdinas [ -i | -I | -D default ] [ -n ] var remainder..." +#define USAGE "withstdinas [ -i | -I | -D default ] [ -N | -n ] var remainder..." #define dieusage() strerr_dieusage(100, USAGE) int main (int argc, char const **argv, char const *const *envp) @@ -17,17 +17,18 @@ int main (int argc, char const **argv, char const *const *envp) subgetopt_t localopt = SUBGETOPT_ZERO ; stralloc modif = STRALLOC_ZERO ; size_t modifstart ; - int insist = 0, chomp = 0 ; + int insist = 0, chomp = 1 ; char const *def = 0 ; PROG = "withstdinas" ; for (;;) { - int opt = subgetopt_r(argc, argv, "iInD:", &localopt) ; + int opt = subgetopt_r(argc, argv, "iINnD:", &localopt) ; if (opt < 0) break ; switch (opt) { case 'i' : insist = 2 ; break ; case 'I' : insist = 1 ; break ; + case 'N' : chomp = 0 ; break ; case 'n' : chomp = 1 ; break ; case 'D' : def = localopt.arg ; break ; default : dieusage() ; diff --git a/src/libexecline/exlsn_define.c b/src/libexecline/exlsn_define.c index 3e7429c..f2f5c4a 100644 --- a/src/libexecline/exlsn_define.c +++ b/src/libexecline/exlsn_define.c @@ -16,10 +16,11 @@ int exlsn_define (int argc, char const **argv, char const *const *envp, exlsn_t blah.value = info->values.len ; for (;;) { - int opt = subgetopt_r(argc, argv, "nsCcd:", &localopt) ; + int opt = subgetopt_r(argc, argv, "NnsCcd:", &localopt) ; if (opt < 0) break ; switch (opt) { + case 'N' : si.chomp = 0 ; break ; case 'n' : si.chomp = 1 ; break ; case 's' : si.split = 1 ; break ; case 'C' : si.crunch = 1 ; break ; diff --git a/src/libexecline/exlsn_importas.c b/src/libexecline/exlsn_importas.c index d8d9ff6..f23c055 100644 --- a/src/libexecline/exlsn_importas.c +++ b/src/libexecline/exlsn_importas.c @@ -23,13 +23,14 @@ int exlsn_importas (int argc, char const **argv, char const *const *envp, exlsn_ for (;;) { - int opt = subgetopt_r(argc, argv, "iuD:nsCcd:", &localopt) ; + int opt = subgetopt_r(argc, argv, "iuD:NnsCcd:", &localopt) ; if (opt < 0) break ; switch (opt) { case 'i' : insist = 1 ; break ; case 'u' : unexport = 1 ; break ; case 'D' : defaultval = localopt.arg ; break ; + case 'N' : si.chomp = 0 ; break ; case 'n' : si.chomp = 1 ; break ; case 's' : si.split = 1 ; break ; case 'C' : si.crunch = 1 ; break ; diff --git a/src/libexecline/exlsn_multidefine.c b/src/libexecline/exlsn_multidefine.c index c28d926..38147e6 100644 --- a/src/libexecline/exlsn_multidefine.c +++ b/src/libexecline/exlsn_multidefine.c @@ -22,12 +22,13 @@ int exlsn_multidefine (int argc, char const **argv, char const *const *envp, exl si.split = 1 ; for (;;) { - int opt = subgetopt_r(argc, argv, "0rnCcd:", &localopt) ; + int opt = subgetopt_r(argc, argv, "0rNnCcd:", &localopt) ; if (opt < 0) break ; switch (opt) { case '0' : zeroword = 1 ; break ; case 'r' : likeread = 1 ; break ; + case 'N' : si.chomp = 0 ; break ; case 'n' : si.chomp = 1 ; break ; case 'C' : si.crunch = 1 ; break ; case 'c' : si.crunch = 0 ; break ; |