aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-12-02 05:26:25 +0100
committerMattias Andrée <maandree@operamail.com>2015-12-02 05:26:25 +0100
commit3906ade6a031f1fc97d49b09e867814e304abafd (patch)
tree42f9bd5c48feefe6c58c8fd964a6ce192aee3daa
parentadd info manual (diff)
downloadexec-as-3906ade6a031f1fc97d49b09e867814e304abafd.tar.gz
exec-as-3906ade6a031f1fc97d49b09e867814e304abafd.tar.bz2
exec-as-3906ade6a031f1fc97d49b09e867814e304abafd.tar.xz
do not require argv[0], it is possible to only specify the file to run, and let argv be empty
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--README4
-rw-r--r--doc/info/exec-as.texinfo2
-rw-r--r--doc/man/exec-as.16
-rw-r--r--src/exec-as.c10
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);