diff options
| author | Mattias Andrée <m@maandree.se> | 2026-02-22 13:06:33 +0100 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-02-22 13:06:33 +0100 |
| commit | eaef2ea44cc6f3d5f637a95ff0f171b0cf7c6acc (patch) | |
| tree | e2e2a9db28fc174a029dbf757944a9236b730ee8 | |
| parent | Update e-mail (diff) | |
| download | exec-as-f4cdd5b1ec63e2bcbfc0cc1d07c3d33d868491df.tar.gz exec-as-f4cdd5b1ec63e2bcbfc0cc1d07c3d33d868491df.tar.bz2 exec-as-f4cdd5b1ec63e2bcbfc0cc1d07c3d33d868491df.tar.xz | |
Signed-off-by: Mattias Andrée <m@maandree.se>
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | README | 10 | ||||
| -rw-r--r-- | config.mk | 4 | ||||
| -rw-r--r-- | exec-as.1 | 8 | ||||
| -rw-r--r-- | exec-as.c | 5 |
5 files changed, 16 insertions, 13 deletions
@@ -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" @@ -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) @@ -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 @@ -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) @@ -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; } |
