pthbs

Packaging Through Hashed Build Scripts
git clone https://ccx.te2000.cz/git/pthbs
Log | Files | Refs | Submodules | README

commit dd6991f169e1b602b9451781936d854ffe7d7448
parent 8235852bbbe0ddb92818245bec64f1a6bba92df6
Author: Jan Pobříslo <ccx@te2000.cz>
Date:   Mon, 19 Feb 2024 22:46:49 +0100

Add tiny program that finds it's basename(argv[0]) in path and runs it.

Diffstat:
Afiles/argv0exec | 0
Afiles/argv0exec.c | 17+++++++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/files/argv0exec b/files/argv0exec Binary files differ. diff --git a/files/argv0exec.c b/files/argv0exec.c @@ -0,0 +1,17 @@ +#include <skalibs/exec.h> + +int main (int argc, const char const **argv) +{ + const char *new_argv[argc + 1]; + for(size_t i = 0; i < argc; i++) { + new_argv[i] = argv[i]; + } + new_argv[argc] = 0; + + for(size_t i = 0; argv[0][i]; i++) { + if(argv[0][i] == '/') { + new_argv[0] = &argv[0][i+1]; + } + } + xexec(new_argv); +}