From ac617315854d7985105a6cf341a5c0153fe3e35d Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 1 Feb 2019 14:51:31 -0600 Subject: Fix record-commands and logwrapper.c record-commands: Delete old log, only delete $WRAPDIR at end if path wasn't externally supplied, don't add the rm at the end to the log. logwrapper.c: don't skip filename when measuring space for command line malloc, use argv[0] instead of /proc/self/exe (which is realpath -f). --- toys/example/logwrapper.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'toys/example') diff --git a/toys/example/logwrapper.c b/toys/example/logwrapper.c index 0f87df24..036fcd32 100644 --- a/toys/example/logwrapper.c +++ b/toys/example/logwrapper.c @@ -29,7 +29,7 @@ void logwrapper_main(void) // Log the command line if (!log) error_exit("no $WRAPLOG"); len = strlen(omnom)+2; - for (i = 1; istr, s)) break; + if (!strcmp(list->str, *toys.argv)) break; free(llist_pop(&list)); } } @@ -69,7 +66,9 @@ void logwrapper_main(void) // Skip first instance and try to run next one, until out of instances. for (;;) { if (list) free(llist_pop(&list)); - if (!list) error_exit("no %s after logwrapper in $PATH", omnom); + if (!list) + error_exit("no %s after %s in $PATH=%s", omnom, + **toys.argv == '/' ? *toys.argv : "logwrapper", getenv("PATH")); *toys.argv = list->str; execve(list->str, toys.argv, environ); } -- cgit v1.2.3