diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2015-11-02 22:22:28 +0100 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2015-11-02 22:22:28 +0100 |
commit | 7f9da0f4ea465bd15572ea4c2b063fe4f66d7c8f (patch) | |
tree | ed82ad7e487115efc5e8659244eb6e547d1b2e35 | |
parent | 150e30f830d37c6ad2f71278cd43f3ac6cf150f2 (diff) | |
download | xe-7f9da0f4ea465bd15572ea4c2b063fe4f66d7c8f.tar.gz xe-7f9da0f4ea465bd15572ea4c2b063fe4f66d7c8f.tar.xz xe-7f9da0f4ea465bd15572ea4c2b063fe4f66d7c8f.zip |
add -k
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | xe.c | 13 |
2 files changed, 9 insertions, 7 deletions
diff --git a/README.md b/README.md index 9cbab20..1940209 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,13 @@ Over apply: ## Usage: - xe [-0nv] [-I arg] [-N maxargs] [-j maxjobs] COMMAND... + xe [-0knv] [-I arg] [-N maxargs] [-j maxjobs] COMMAND... | -s SHELLSCRIPT | -a COMMAND... -- ARGS... | -A ARGSEP COMMAND... ARGSEP ARGS... * `-0`: input filenames are seperated by NUL bytes (default: newlines). +* `-k`: keep going: don't stop when a command failed to execute. * `-n`: don't run the commands, just print them. * `-v`: print commands before running them. * `-I`: replace occurences of *arg* with the argument (default: `{}`). diff --git a/xe.c b/xe.c index 5e4dcbf..2578b6d 100644 --- a/xe.c +++ b/xe.c @@ -29,7 +29,7 @@ static char *sflag; static int maxatonce = 1; static int maxjobs = 1; static int runjobs = 0; -static int aflag, nflag, vflag; +static int aflag, kflag, nflag, vflag; static char * xstrdup(const char *s) @@ -79,7 +79,7 @@ mywait() // no other error possible? } - if (WIFEXITED(status)) { + if (WIFEXITED(status) && !kflag) { if (WEXITSTATUS(status) >= 1 && WEXITSTATUS(status) <= 125) { exit(123); } else if (WEXITSTATUS(status) == 255) { @@ -181,20 +181,21 @@ main(int argc, char *argv[]) int i, cmdend; char *arg, **cmd; - while ((c = getopt(argc, argv, "+0A:I:N:anj:s:v")) != -1) + while ((c = getopt(argc, argv, "+0A:I:N:aj:kns:v")) != -1) switch(c) { case '0': delim = '\0'; break; case 'A': argsep = optarg; aflag++; break; - case 'I': replace = optarg; break; + case 'I': replace = optarg; break; case 'N': maxatonce = atoi(optarg); break; case 'a': aflag++; break; - case 'n': nflag++; break; case 'j': maxjobs = atoi(optarg); break; + case 'k': kflag++; break; + case 'n': nflag++; break; case 's': sflag = optarg; break; case 'v': vflag++; break; default: fprintf(stderr, - "Usage: %s [-0nv] [-I arg] [-N maxargs] [-j maxjobs] COMMAND...\n" + "Usage: %s [-0knv] [-I arg] [-N maxargs] [-j maxjobs] COMMAND...\n" " | -s SHELLSCRIPT\n" " | -a COMMAND... -- ARGS...\n" " | -A ARGSEP COMMAND... ARGSEP ARGS...\n", |