From 3906ade6a031f1fc97d49b09e867814e304abafd Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 2 Dec 2015 05:26:25 +0100 Subject: do not require argv[0], it is possible to only specify the file to run, and let argv be empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- README | 4 ++-- doc/info/exec-as.texinfo | 2 +- doc/man/exec-as.1 | 6 +++--- src/exec-as.c | 10 ++++------ 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/README b/README index a1fce3f..b162617 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ NAME exec-as - exec(1) with explicit argv[0] SYNOPSIS - exec-as FILE ARGV0 [ARGV]... + exec-as FILE [ARGV0 [ARGV]...] DESCRIPTION exec-as shall spawn the program FILE, using execvp(3), @@ -10,7 +10,7 @@ DESCRIPTION arguments for the following values in argv. NOTES - At least two arguments is required. Since this is not + At least one argument is required. Since this is not a builtin function, it cannot be used as exec(1) without arguments to set file descriptors. diff --git a/doc/info/exec-as.texinfo b/doc/info/exec-as.texinfo index e918650..69f8850 100644 --- a/doc/info/exec-as.texinfo +++ b/doc/info/exec-as.texinfo @@ -83,7 +83,7 @@ exec, you need to use @command{exec} too: @node Invoking @chapter Invoking -At least two arguments are required. The first +At least one argument are required. The first argument is the file to run. This can either be an absolute path, an explicitly relative path, or a file in @env{$PATH}. The second argument diff --git a/doc/man/exec-as.1 b/doc/man/exec-as.1 index 27c4481..f66bb9d 100644 --- a/doc/man/exec-as.1 +++ b/doc/man/exec-as.1 @@ -4,8 +4,8 @@ exec-as - passphrase strength evaluator .SH SYNOPSIS .B exec-as .I FILE -.I ARGV0 -.RI [ ARGV ]... +.RI [ ARGV0 +.RI [ ARGV ]...] .SH DESCRIPTION .B exec-as shall spawn the program @@ -19,7 +19,7 @@ as the value for and the following arguments for the following values in .BR argv . .SH NOTES -At least two arguments is required. Since this is not +At least one argument is required. Since this is not a builtin function, it cannot be used as .BR exec (1) without arguments to set file descriptors. diff --git a/src/exec-as.c b/src/exec-as.c index 9e5fbfe..842dc82 100644 --- a/src/exec-as.c +++ b/src/exec-as.c @@ -25,19 +25,17 @@ int main(int argc, char** argv) char* file; int i; - if (argc < 3) + if (argc < 2) { fprintf(stderr, "%s: %s", argc ? argv[0] : "exec-as", - "Too few arguments, you need at least " - "the file to run and its argv[0]."); + "Too few arguments, you need at least the file to run."); goto fail; } execname = argv[0]; - file = argv[1]; - for (i = 0; i < argc - 2; i++) - argv[i] = argv[i + 2]; + for (i = 0; i < argc - 1; i++) + argv[i] = argv[i + 12]; argv[i] = NULL; execvp(file, argv); -- cgit v1.2.3-70-g09d2