From 2c7d28aaa222a84df9519251fd893152b1eb1517 Mon Sep 17 00:00:00 2001 From: BanceDev Date: Thu, 12 Sep 2024 14:16:14 -0400 Subject: added non interative mode for running lua scripts --- .github/workflows/build.yml | 5 +---- src/lush.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0fcd9fd..91955e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,11 +53,8 @@ jobs: - name: Run Lua tests run: | - /usr/bin/lush < 1) { + char *ext = strrchr(argv[1], '.'); + if (ext) { + ext++; + if (strcmp(ext, "lua") == 0) { + int status = 0; + argv++; + char ***args = lush_split_args(argv, &status); + + if (status == -1) { + fprintf(stderr, "lush: Expected end of quoted string\n"); + } else if (lush_run(L, args, status) == 0) { + exit(1); + } + + for (int i = 0; args[i]; i++) { + free(args[i]); + } + free(args); + return status; + } + } + } + // eat ^C in main struct sigaction sa; sa.sa_handler = SIG_IGN; -- cgit v1.2.3-59-g8ed1b