Last active
October 12, 2023 09:12
-
-
Save sogaiu/cadaae38a66dbbd480141496af04f7af to your computer and use it in GitHub Desktop.
sh/exec-slurp via janet_dostring (assuming spork is installed)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// build: | |
// | |
// gcc -O0 -g main.c -I$HOME/.local/include -L$HOME/.local/lib -ljanet | |
// run: | |
// | |
// export LD_LIBRARY_PATH=$HOME/.local/lib | |
// ./a.out | |
#include "janet.h" | |
#include <stdio.h> | |
int main() { | |
JanetTable *env; | |
janet_init(); | |
env = janet_core_env(NULL); | |
int status = | |
janet_dostring(env, | |
"(import spork/sh) (pp (sh/exec-slurp `uname`))", | |
"source", NULL); | |
printf("result: %d\n", status); | |
janet_deinit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment