-
-
Save iacore/6acbb2d98403e468c35dd835518b9be5 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); | |
Janet out; | |
int status = | |
janet_dostring(env, | |
"(import spork/sh) (sh/exec-slurp `uname`)", | |
"source", &out); | |
printf("result: %d\n", status); | |
printf("is string: %d\n", janet_checktype(out, JANET_STRING)); | |
printf("is nil: %d\n", janet_checktype(out, JANET_NIL)); | |
janet_deinit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try addingjanet_loop
after the call to janet_dostring. thejanet_do*
functions do not enter the event loopEDIT: My mistake, that support is added. however, the result that is returned is not useful.