From eaef2ea44cc6f3d5f637a95ff0f171b0cf7c6acc Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 22 Feb 2026 13:06:33 +0100 Subject: m fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 2 +- README | 10 +++++----- config.mk | 4 ++-- exec-as.1 | 8 ++++---- exec-as.c | 5 ++++- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 914e682..6feb7b6 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ all: exec-as test $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) check: exec-as test - test "$$(./exec-as ./test 1 2 3)" = "1,3" + test "$$(./exec-as ./test 1 2 3)" = "1,3" install: exec-as mkdir -p -- "$(DESTDIR)$(PREFIX)/bin" diff --git a/README b/README index 26a3b28..1bb3ece 100644 --- a/README +++ b/README @@ -11,18 +11,18 @@ DESCRIPTION NOTES At least one argument is required. Since this is not - a builtin function, it cannot be used as exec(1) without + a built-in function, it cannot be used as exec(1) without arguments to set file descriptors. - Because this is not a builtin function, running this - program would normally do an fork–exec rather than + Because this is not a built-in function, running this + program would normally do a fork–exec rather than just an exec. To just perform an exec, you need to use exec(1) too: exec exec-as EXAMPLES 'exec-as bash -bash' will run the first program in - $PATH named bash, and set argv[0] to -bash (making it - a login shell.) You can add addition argument as needed. + $PATH named bash, and set argv[0] to -bash (making it a + login shell.) You can add additional arguments as needed. SEE ALSO exec(1), exec(3) diff --git a/config.mk b/config.mk index aa81003..bc78e3e 100644 --- a/config.mk +++ b/config.mk @@ -1,8 +1,8 @@ PREFIX = /usr MANPREFIX = $(PREFIX)/share/man -CC = cc +CC = c99 CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -CFLAGS = -std=c99 -Wall -O2 +CFLAGS = LDFLAGS = -s diff --git a/exec-as.1 b/exec-as.1 index a52199f..a550f62 100644 --- a/exec-as.1 +++ b/exec-as.1 @@ -20,12 +20,12 @@ and the following arguments for the following values in .BR argv . .SH NOTES At least one argument is required. Since this is not -a builtin function, it cannot be used as +a built-in function, it cannot be used as .BR exec (1) without arguments to set file descriptors. .PP -Because this is not a builtin function, running this -program would normally do an fork–exec rather than +Because this is not a built-in function, running this +program would normally do a fork–exec rather than just an exec. To just perform an exec, you need to use .BR exec (1) @@ -41,7 +41,7 @@ and set .B argv[0] to .B \-bash -(making it a login shell.) You can add addition argument as needed. +(making it a login shell.) You can add additional arguments as needed. .SH "SEE ALSO" .BR exec (1), .BR exec (3) diff --git a/exec-as.c b/exec-as.c index 64a0f27..a5f5ed6 100644 --- a/exec-as.c +++ b/exec-as.c @@ -8,11 +8,14 @@ int main(int argc, char *argv[]) { + int ret; if (argc < 2) { fprintf(stderr, "usage: %s command [argv0 [arg ...]]\n", argc ? argv[0] : "exec-as"); + ret = 125; } else { execvp(argv[1], &argv[2]); + ret = errno == ENOENT ? 127 : 126; fprintf(stderr, "%s: execvp %s: %s\n", argv[0], argv[1], strerror(errno)); } - return 138; + return ret; } -- cgit v1.2.3-70-g09d2